Can someone help me figure out what's going on with this code? I've been pulling my hair out trying to work with JSON from the Instagram API. When I console log 'body', I see the JSON data, but when I try to access properties like 'body.data' or 'body.pagination', I get nothing! Please help, and thank you in advance.
var express = require("express"),
app = express(),
https = require("https"),
fs = require("fs"),
request = require("request");
request("https://api.instagram.com/v1/tags/nofilter/media/recent?access_token=xxxxx&scope=public_content&count=1", function(error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body); // prints the full JSON response
console.log(body.data); // **this returns undefined!!!!!**
}
}).pipe(fs.createWriteStream("./test.txt"));