Reputation: 63
I'm using the webcams.travel API from RapidAPI (link to API doc) and I've set everything up using browserify, unirest, node, require, etc.
The API response is in json and the Response Header is being output, but the Response Body is supposed to give me an object with webcams, but instead it shows as "undefined". This is my output now:
Is the problem in the parsing of the json, or does it have something to do with unirest? I'm thankful for any help.
Code in my app.js (which is the suggested request snippet from the API site):
var unirest = require('unirest');
unirest.get("https://webcamstravel.p.rapidapi.com/webcams/list/continent=AN?lang=en&show=webcams%3Aimage%2Clocation")
.header("X-RapidAPI-Key", "MY_RAPID_API_KEY")
.end(function (result) {
console.log(result.status, result.headers, result.body);
});
Upvotes: 5
Views: 1701
Reputation: 15055
Following up because I got interest—I eventually solved this issue when I encountered it with Imgur’s API by using the Fetch API instead of Unirest. There seems to be some issue with RapidAPI and Unirest, but when I contacted support they were unaware of any issues.
I recommend trying fetch() if you’re still encountering this.
Upvotes: 1