Exemple API en TD : team imdb

master
Juan 3 years ago
parent 462c9153b5
commit 8b9aaebc5c

@ -0,0 +1,8 @@
const FilmAPI = require('./imdb')
const asyncApiCall = async () => {
const response = await FilmAPI.getFilm('Avengers Endgame')
// console.log(response.data.data.getFilm.heading)
console.log(response)
}
asyncApiCall()

@ -0,0 +1,19 @@
const axios = require("axios");
const BASE_URL = `https://imdb8.p.rapidapi.com/title/find`
module.exports = {
getFilm: (whichFilm) => axios({
method:"GET",
url : BASE_URL,
headers: {
"content-type": "application/json",
"x-rapidapi-host": "imdb8.p.rapidapi.com",
"x-rapidapi-key": "6ab6142a4fmsh81bced26e343a0cp1dd24cjsn97139b9afab0"
},
params: {
q: whichFilm
}
})
}

@ -0,0 +1,17 @@
{
"name": "api-call",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.25.0",
"esm": "^3.2.25"
},
"devDependencies": {},
"description": ""
}
Loading…
Cancel
Save