-
-
Save georules/e4dbf5fb05ecac3380236ae49c0298b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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