URLSession Requests from a Widget

My widget needs to get that from an API to generate its timeline.

In the 3rd video of the Widget Code-Along the presenter says that the in-process foreground URLSessions should work as expected.

My widget gets stuck at placeholder view and never shows the real data.

Everything works fine and the widget renders as expected when I use some dummy data to generate the timeline.

Anybody, any success with fetching data from the Internet in a widget?
Answered by ekurutepe in 618638022
Answering my own question: This works just fine. Here is a great tutorial on how to use URLSessions in widgets. (tl;dr: no special considerations necessary) (This does not allow me to link the URL but search for Oliver Binns WidgetKit)

In my case the problem was because with data from the network, my widget was running against the 30MB memory limit.
Accepted Answer
Answering my own question: This works just fine. Here is a great tutorial on how to use URLSessions in widgets. (tl;dr: no special considerations necessary) (This does not allow me to link the URL but search for Oliver Binns WidgetKit)

In my case the problem was because with data from the network, my widget was running against the 30MB memory limit.
Hi, I'm currently working with WidgetKit and wanna fetching data from api like your question.

Can you tell me how you do it in your code? Where to call URLRequest? Can I calling the request inside the widget class? Because put both layout and logic code in same file seem like a bad idea.
URLSession Requests from a Widget
 
 
Q