how to sync your app with a backend http request

how do i implement a sync with my backend api incase i temporarily loose network connection?

I think the easiest way is probably to save all your state to disk as JSON. And when you have a connection again you can check if there is any data needed to be synced