reading-notes

Reading Notes

View the Project on GitHub simon-panek/reading-notes

Code 401: Class 01 - Node Ecosystem, TDD, CI/CD


Questions

  1. Array.map() takes an array and creates a new array with the results of a function called on every element of the original array

  2. Array.reduce() produces a single result from running a function on each element of a given array

  3. Superagent()


  let getCharacters = () => {
  superagent.get (`https://swapi.dev/api/people`)
    .then( data => {
      console.log(`{ ${data.body.results[0].name} : ${data.body.results[0].url} }`);
    }) 
    .catch(err => {
      console.error('Something broke:', err);
    })
  }

  getCharacters();
 

    async function getCityData () {
    let cities = ['Houston', 'Duvall', 'Carnation', 'Seattle', 'Tunis', 'Bellingham'];
    for (let i=0; i<cities.length; i++){
    try {
      let results = await superagent.get(`https://geocode.xyz/${cities[i]}?json=1`)
        console.log(cities[i], ' --> Latitude: ', results.body.latt, ' Longitude: ', results.body.longt);
    }
    catch { err => console.log(err)};
    }
    }

    getCityData();

  1. Promise a promise allows an asynchronous to provide a temporary result inline which is then defined when the promise is resolved

  2. Callback Functions not all callback functions are asynchronous, typically asynchronous functions pull in information from outside processes or resources


Return to reading-notes Deployed Site

Return to reading-notes Mark Down