I want to extract an array from the public API, and all I'm receiving is a promise
. How can I return the array from the API, outside my function?
Please have a look at the code I'm trying to implement:
var getMov = function() {
return fetch('http://localhost:8080/api/projects')
.then((response) => response.json())
.then((responseJson) => {
JSON.parse(responseJson.movies);
return responseJson.movies;
})
};
console.log(getMov());
Let me know if you have any ideas, how to solve this promise issue.