0

Is there any way to have a refresh "function" on AMP pages to repeat a task every X seconds?

I need to call and API url every X seconds and with the response, modify part of page content.

In javascript I was doing it with setTimeout, but I could not find anything that would do it in AMP.

I've checked amp-bind refresh state, but it seems that it only works for tapping interactions.

<div>
    <amp-state id="time"
      src="/components/time"></amp-state>
    <button on="tap:time.refresh">
      Refresh
    </button>
    <div [text]="time"></div>
  </div>
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
  • 1
    Please take into account the AMP cache. If you expect the frequent data updates then you will need to flush the AMP cache too, otherwise Google will serve the cached content, see more details [here](https://developers.google.com/amp/cache/update-cache) – Kate Orlova Jun 05 '19 at 18:02
  • Thank you Kate, gonna consider this point also – Ricardo B P Jun 05 '19 at 23:16
  • https://amp.dev/documentation/examples/components/amp-live-list/ perhaps? – fstanis Jun 06 '19 at 02:23

0 Answers0