I am currently enrolled in Colt Steele's Web Developer bootcamp and facing a challenge...
In the tutorial, we are using axios as 'request' has been discontinued, so I am trying to follow along with this change.
My goal is to set up a Get route for a '/results' page, where I can retrieve information from the OMDB Movie Database and display the JSON file when I visit the URL.
Despite hours of searching, I have not been able to find a solution. Here is my code:
const express = require('express');
const app = express();
const axios = require('axios').default;
app.listen(3000, () => {
console.log('Im listening');
});
app.get('/results', (req, res) => {
axios.get('http://www.omdbapi.com/?t=california&apikey=thewdb')
.then((response) => {
res.send(response);
}).catch((err) => {
console.log('This isnt right');
})
});
I also have express installed correctly. When I use console.log(response) like this:
axios.get('http://www.omdbapi.com/?t=california&apikey=thewdb')
.then((response) => {
console.log(response);
}).catch((err) => {
console.log('This isnt right');
})
The API JSON is displayed in my console, which leads me to believe there might be an issue with using res.send(response) in the promise.
Any assistance would be highly appreciated. Sorry if I missed any important details, I'm still learning...