Looks like your widget is stuck on the placeholder because the timeline might not be completing properly. Two things to check:
In your getData function, the network response is on a background thread. You should call completion(jsonData) on the main thread, like:
swift
Copy
Edit
DispatchQueue.main.async {
completion(jsonData)
}
Also double-check that your API endpoint returns valid JSON on every request. You might want to add a fallback if decoding fails, or print the data as a string for debugging.
I'm using a similar setup for Panchang data in a widget using Divine API, it works well once the timeline refresh is handled properly.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: