Advertisement
Guest User

Untitled

a guest
May 2nd, 2022
12
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const https = require('https')
  2. let url = 'https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY'
  3. https.get(url, res => {
  4.     let rawData = ''
  5.     res.on('data', chunk=> {
  6.         rawData += chunk
  7.     })
  8.    
  9.     res.on('end', () => {
  10.         const parsedData = JSON.parse(rawData)
  11.         console.log(parsedData)
  12.     })
  13.    
  14.     res.on("error", error => {
  15.         console.log(error);
  16.     })
  17. });
Advertisement
RAW Paste Data Copied
Advertisement