I was learning making api calls. So I started using OMDB api to get movie information.
fetch(http: //www.omdbapi.com/?apikey=f69f0628&s=batman )
.then((success) => {
success.json()
})
.then((movies) => {
console.log(movies)
})
.catch((err) => {
console.log(err)
});
The above code gives me the error in firefox
SyntaxError: missing ) after argument list
When I do this (added single quotes to the url) :
fetch('http://www.omdbapi.com/?apikey=f69f0628&s=batman')
.then((success) => {
success.json()
})
.then((movies) => {
console.log(movies)
})
.catch((err) => {
console.log(err)
});
It gives the console log:
undefined
The problem is at line .then((success) =>{ success.json() } )
it should be .then((success) => success.json() )
without { }
Or .then((success) =>{ return success.json() } )
You can find detail of arrow function here
fetch('http://www.omdbapi.com/?apikey=f69f0628&s=batman')
.then((success) => success.json())
.then((movies) => {
console.log(movies)
})
.catch((err) => {
console.log(err)
});