Widget with content updated from REST api

Hi,
I'm developing a widget extension that show content from REST api.
It show the updated following stock info.


I intend to build a workflow like that:
  1. Fetch list from api

  2. Create a timeline with only 1 timeline entry & attach the stocks into timeline entry

  3. Render widget

  4. Reload new timeline at next 5 minutes

My problem is:Any helps are welcome!
Can anyone point me out how to do this?
The video guide Widgets Code-along, part 3: Advancing timelines doesn't help me.


here my code:

Code Block swift
public func timeline(
  for configuration: ConfigurationIntent,
  with context: Context,
  completion: @escaping (Timeline<Entry>) -> ()
 ) {
  print("Provider.timeline: ")
   
  fetchStocks { (stocks: [Stock], error: Bool) in
   print("fetchStocks: stocks: ", stocks)
   completion(getTimeLineFromStocks(stocks: stocks, for: configuration, with: context, reloadPolicy: .atEnd))
  }
 }
func getTimeLineFromStocks(
  stocks: [Stock],
  for configuration: ConfigurationIntent,
  with context: Context,
  reloadPolicy: TimelineReloadPolicy
 ) -> Timeline<Entry> {
  var entries: [SimpleEntry] = []
  let currentDate = Date()
  entries.append(SimpleEntry(
   date: Calendar.current.date(byAdding: .second, value: 15, to: currentDate)!,
   configuration: configuration,
   stocks: stocks
  ))
   
  let timeline = Timeline(entries: entries, policy: reloadPolicy)
   
  return timeline
 }


My log show Provider.timeline was called to much:

Code Block language
Provider.timeline: 
2020-07-23 16:58:07.365505+0700 money24h-widgetExtension[5217:1242454] libMobileGestalt MobileGestaltCache.c:166: Cache loaded with 4563 pre-cached in CacheData and 53 items in CacheExtra.
Provider.timeline: 
Provider.timeline: 
Provider.timeline: 
Provider.timeline: 
Provider.timeline: 
Provider.timeline: 
Provider.timeline: 
Provider.timeline: 
Provider.timeline: 
Provider.timeline: 
Provider.timeline: 
Provider.timeline: 
Provider.timeline: 
2020-07-23 16:58:07.770693+0700 money24h-widgetExtension[5217:1242454] [widget] No intent in timeline(for:with:completion:)


It mean fetchStocks was also called 14 times?
That weird!

Widget with content updated from REST api
 
 
Q