Skip to content

Instantly share code, notes, and snippets.

@georules
Created May 31, 2019 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save georules/e4dbf5fb05ecac3380236ae49c0298b6 to your computer and use it in GitHub Desktop.
Save georules/e4dbf5fb05ecac3380236ae49c0298b6 to your computer and use it in GitHub Desktop.
var rp = require('request-promise');
const m = require('moment')
const url = 'https://api.openweathermap.org/data/2.5/weather?q=Tallahassee,US&appid=d15dd962af5867dfbfeee729a5b05736'
console.log(url)
rp(url)
.then(function (htmlString) {
//console.log(htmlString)
const data = JSON.parse(htmlString)
//console.log(data)
const celcius = data.main.temp - 273.1
console.log(celcius*(9/5)+ 32)
})
.catch(function (err) {
// Crawling failed...
});
// crazy stuff under here
const now1 = m()
rp(url)
.then((html) => {
//console.log(html)
const data = JSON.parse(html)
//console.log(data)
const celcius = data.main.temp - 273.1
console.log(celcius*(9/5)+ 32)
const now4 = m()
console.log(now4.diff(now1))
})
const now2 = m()
const ms1 = now2.diff(now1)
rp(url)
.then((html) => {
//console.log(html)
const data = JSON.parse(html)
//console.log(data)
const celcius = data.main.temp - 273.1
console.log(celcius*(9/5)+ 32)
})
const now3 = m()
const ms2 = now3.diff(now2)
ms3 = now3.diff(now1)
console.log(ms1, ms2, ms3)
async function main() {
const now1 = m()
await rp(url)
const now2 = m()
await rp(url)
const now3 = m()
const ms1 = now2.diff(now1)
const ms2 = now3.diff(now2)
const ms3 = now3.diff(now1)
console.log(ms1, ms2, ms3)
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment