Created
July 13, 2018 19:04
-
-
Save jonasjohansson/595eeca650f7d73138c71d9a4ad87066 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
const lat = '56.937783'; | |
const lon = '12.384565899999984'; | |
const url = `https://api.met.no/weatherapi/locationforecastlts/1.3/?lat=${lat}&lon=${lon}`; | |
fetch(url) | |
.then(response => { | |
console.log('response', response); | |
console.log('response.status:', response.status); | |
console.log('response.statusText:', response.statusText); | |
console.log('response.ok:', response.ok); | |
return response.text(); | |
}) | |
.then(responseBody => (new window.DOMParser()).parseFromString(responseBody, "text/xml")) | |
.then(responseBody => { | |
let resp = responseBody.getElementsByTagName('temperature')[0].getAttribute("value"); | |
// console.log('responseBody:', responseBody); | |
console.log('resp:', resp); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment