Skip to content

Instantly share code, notes, and snippets.

@teasmade
Created June 8, 2021 14:26
Show Gist options
  • Save teasmade/0d167c68a66eed9f4ecdbbb56b7b4183 to your computer and use it in GitHub Desktop.
Save teasmade/0d167c68a66eed9f4ecdbbb56b7b4183 to your computer and use it in GitHub Desktop.
const request = require('request');
request('https://swapi.dev/api/people/1/', function (error, response, body) {
// console.error('error:', error); // Print the error if one occurred
// console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
// console.log('body:', body); // Print the body
let luke = JSON.parse(body);
console.log(luke);
console.log(luke.films);
request('http://swapi.dev/api/films/1/', function (errorF, responseF, bodyF) {
let film = JSON.parse(bodyF);
console.log(film.title);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment