Reputation: 195
I'm creating little app using API TheMovie DB. My function responsible for fetching data looks like this:
movieSearch(term){
const request = axios.get(`${ROOT_URL}${API_KEY}&query=${term}`);
console.log(request);
}
Result in console looks like this: link How can i reach "response" field?
Upvotes: 1
Views: 778
Reputation: 16246
The axios.get()
returns a Promise object (what you see in the screenshot). To get the response
of HTTP request, you need to invoke that Promise object's then()
function:
axios.get('http://<your address>')
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
For more information on Promise and its usage, you can refer to Promise - JavaScript | MDN.
Upvotes: 1