I'm trying to call an API when the "http-on-modify-request" fire in my firefox addon.
So for now, here is my code :
Request({
url: "https://myAPI.com/?q="+query,
onComplete: function (response) {
var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
httpChannel.redirectTo(ioService.newURI(response.json.Redirect, null, null));
}
}).get();
Unfortunately, as it's asynchronous, the first query which fire the observer is already done, so it can't redirect.
Is there another way I can do that ?