When using amplify.request, I'd like to use amplify.store to persist the results from each call. I know I can do this with this code:
amplify.request.define( "ajaxExample2", "ajax", {
url: "/myApiUrl",
dataType: "json",
type: "GET",
cache: "persist"
});
However, I'd like to be able to add the results of this to another variable stored with amplify.store but only if the data comes from the server and not from the cache.
For example, I'll make an initial call to amplify.request("ajaxExample2"...
, then I'll save the results to another variable via amplify.store
. Then, the next time I make a call to amplify.request("ajaxExample2"...
, if the data comes from the server, I want to overwrite my local variable - if not, I want to leave it alone.
So, I'd like a way to know if the request makes a server call or not, and call a function if it does. Is there a way to do this with amplify?