View on GitHub

ReadingNotes

Array.map()


Array.reduce()

Example :

superagent() With normal Promise .then() syntax:

function getMovies(req , res){
const city = req.query.search_query;
const url = `https://api.themoviedb.org/3/movie/top_rated` //?city=${city}&key=${PARKS_API_KEY}`;
const quryParams = {
    query :city,
    api_key:MOVIE_API_KEY,

};
// console.log(quryParams);
superagent.get(url , quryParams).then(dataFromAPI=>{
const movies = dataFromAPI.body.results.map(data => new Movies (data));
res.send(movies);})

superagent() with async / await syntax :

promises

When a Promise object is “fulfilled”, the result is a value.

When a Promise object is “rejected”, the result is an error object.

Example :

Are all callback functions considered to be Asynchronous?


Home