I want to return a some information in a json format so I can assign variables to them. I’m using Axios to get some json info on movies but can’t seem to assign a variable to the data, as I always get ‘undefined’ in the output. Any fixes?
Here’s my code, as you can see I’m trying to return something from the function then assign a value to it.
function getMovie(movie){
axios.get('http://www.omdbapi.com?t='+movie+'&apikey='+APIKEY)
.then((response) => {
console.log(response.data);
let info = response.data;
return response.data;
})
.catch((error)=>{
console.log(error);
})
};
let movieInfo = getMovie('Dune');
console.log(movieInfo);