From 8b9aaebc5cc28b14ffa84c7a53582e09a12e57df Mon Sep 17 00:00:00 2001 From: Juan Date: Mon, 24 Jan 2022 16:40:26 +0100 Subject: [PATCH] Exemple API en TD : team imdb --- b3-dev/api/api-td-node/team-imdb/app.js | 8 ++++++++ b3-dev/api/api-td-node/team-imdb/imdb.js | 19 +++++++++++++++++++ b3-dev/api/api-td-node/team-imdb/package.json | 17 +++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 b3-dev/api/api-td-node/team-imdb/app.js create mode 100644 b3-dev/api/api-td-node/team-imdb/imdb.js create mode 100644 b3-dev/api/api-td-node/team-imdb/package.json diff --git a/b3-dev/api/api-td-node/team-imdb/app.js b/b3-dev/api/api-td-node/team-imdb/app.js new file mode 100644 index 0000000..b452467 --- /dev/null +++ b/b3-dev/api/api-td-node/team-imdb/app.js @@ -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() \ No newline at end of file diff --git a/b3-dev/api/api-td-node/team-imdb/imdb.js b/b3-dev/api/api-td-node/team-imdb/imdb.js new file mode 100644 index 0000000..6e0178c --- /dev/null +++ b/b3-dev/api/api-td-node/team-imdb/imdb.js @@ -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 + } + }) +} \ No newline at end of file diff --git a/b3-dev/api/api-td-node/team-imdb/package.json b/b3-dev/api/api-td-node/team-imdb/package.json new file mode 100644 index 0000000..224ddc6 --- /dev/null +++ b/b3-dev/api/api-td-node/team-imdb/package.json @@ -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": "" +}