-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch.js
45 lines (40 loc) · 1.28 KB
/
fetch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
Retrieve needed variables for fetching data from an API
*/
require('dotenv').config()
const utilities = require('./modules/util')
const BASE_URL = 'https://api.themoviedb.org/3'
const URL = `${BASE_URL}/movie/now_playing?api_key=${process.env.API_KEY}` // URL should be modularized more.
/* Execute fetch and log fight club in the console but don't talk about it */
// utilities.getData(`https://api.themoviedb.org/3/movie/550?api_key=${process.env.API_KEY}`)
// .then(
// data => console.log(data)
// )
/* */
// const getCurrentlyPlaying = async () => {
// const data = await utilities.getData(URL)
// // console.log(data.results)
// return await data.results
// .then(data => {
// // console.log(Object.keys(data.results).length) //Get amount of movies currently playing
// // console.log(data.results)
// return data.results
// })
// }
/**
* @title get currently playing movies
* @returns data object of current listing of movies8
*/
const getCurrentlyPlaying = async () => {
const data = await utilities.getData(URL)
return data.results
}
/**
* @title Return data in the console
* @param {Promise} data Object returned by a promise
*/
const msg = async (data) => {
const msg = await data
return console.log(msg)
}
msg(getCurrentlyPlaying())