I am currently trying to get a JSON object out of a function. I can access all the data in the function, but I am struggling to get the data out so I can actually use the Data.
var imdb = require('imdb');
imdb('tt4477536', function(err, data) {
if(err)
console.log(err.stack);
if(data)
console.log(data)
});
This works fine and I get the Data:
{ title: 'Fifty Shades Freed',
year: '2018',
contentRating: 'R',
runtime: '1h 45min',
description: 'Anastasia and Christian get married, but Jack Hyde
continues to threaten their relationship.',
rating: '4.4',
poster: 'https://images-na.ssl-images-amazon.com/images/M/MV5BODI2ZmM5MzMtOWZiMC00ZGE3LTk3MWEtY2U0ZjE3ZWJlNDEzXkEyXkFqcGdeQXVyMTMxODk2OTU@._V1_UX182_CR0,0,182,268_AL_.jpg',
genre: [ 'Drama', ' Romance', ' Thriller' ],
director: 'James Foley',
metascore: '31',
writer: 'Niall Leonard' }
So now my question is how do I get the Data out of this function, so I can actually use the data somewhere else in the code? like if i need the title in a string?
thanking you in advance.
Thomas