Sdk / request always responds with `constructor {}`
I am developing a Firefox Add-on (SDK) and communicating with the Request module. I copied and applied the Twitter-API example from the Mozilla doc to minelib/main.js
var Request = require("sdk/request").Request;
var latestTweetRequest = Request({
url: "https://api.twitter.com/1/statuses/user_timeline.json?screen_name=mozhacks&count=1",
onComplete: function (response) {
var tweet = response.json[0];
console.log("User: " + tweet.user.screen_name);
console.log("Tweet: " + tweet.text);
}
});
Request({
url: "http://api.twitter.com/1/account/rate_limit_status.json",
onComplete: function (response) {
console.log(response); // <--- constructor {}
if (response.json.remaining_hits) {
latestTweetRequest.get();
} else {
console.log("You have been rate limited!");
}
}
}).get();
and run the extension with cfx run
. Then each answer is just
constructor {}
and no error occurs.
I installed REST API on localhost and found that no requests were being made.
What could be causing this?
+3
source to share