Created
April 6, 2018 08:38
-
-
Save kobkrit/3c8163d6845b1a84c62e338266f62582 to your computer and use it in GitHub Desktop.
Api for OMDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rootURL = 'https://www.omdbapi.com/'; | |
exports.search = function(q){ | |
let url = `${rootURL}?apikey=3f1288a7&s=${q}`; | |
console.log(url); | |
return fetch(url) | |
.then((resp)=>resp.json()) | |
.then((json)=>{ | |
return json.Search; | |
}); | |
} | |
exports.view = function(id){ | |
let url = `${rootURL}?apikey=3f1288a7&i=${id}&plot=short&r=json`; | |
return fetch(url) | |
.then((resp)=>resp.json()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment