Closed walshe closed 7 years ago
Your callback should be getting fired. If the response code isn't in the 200s you'll need to check the err
value of the callback.
The best thing you can do is setup some breakpoints in the debugger and watch how the code flows to see what prevents your callback from firing or if something else is wrong.
seems when an err is passed to dispatch that it never comes back to execute the subsequent code, so I had to put in this ugly hack:
static makeRequest(request, store, typeReq, typeRes, callback) {
store.dispatch({
type: typeReq,
request
});
JsonFetch(request, (err, response) => {
if(callback && err && response.statusCode == 401){
callback(err, response);
return
}
store.dispatch({
type: typeRes,
err,
response
});
if (callback) {
callback(err, response);
}
});
}
If an error exists here:
nothing is preventing a callback from being fired. Put a breakpoint on line 39 and 45 and confirm that a callback actually exists.
A 401 would be handled the same as a 400, which we handle today. Like on the login form:
I've shown that stock Aqua does gracefully handle handle 4XX replies from the API.
At this point the best thing to do is create a fork of Aqua with simple changes that reproduce the bug. That way others could clone it and debug themselves.
On the other hand, It sounds like you have started customizing things beyond basic edits, in which case, making a simple reproducible example will probably expose the underlying problem.
This could very well be a bug in Aqua, but we need to pinpoint where it is. Happy hunting. Thanks for being active with the project. 🙏
ok I simplified things a lot and no longer have the issue
I have a rest endpoint locked down with security, and it nicely fails with a 401 code i.e.
I was hoping that I could nicely handle what do do next in my action, callback
but somehow the callback after the store.dispatch() never gets a chance to execute
is this a bug is there something I am missing ? I really want to handle rest calls nicely if token is not available for instance