Created
March 21, 2021 09:59
-
-
Save timuckun/dba4696755ebf350f1a32ad405e9c187 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
This works. | |
```javascript | |
export const T ={ | |
x: "x", | |
y: 1, | |
async f(){ | |
console.log(this.x); | |
console.log(this.y); | |
console.log("called F"); | |
}, | |
async test(){ | |
await this.f() | |
} | |
} | |
``` | |
But this doesn't | |
```javascript | |
export const Api = { | |
async makeApiCall(url) { | |
const response = await fetch(url); | |
if (!response.ok) { | |
throw new Error("Network response was not ok"); | |
} | |
return await response.json(); | |
}, | |
async fetchPwsObservation (station, units, api_key) { | |
const url = | |
"https://api.weather.com/v2/pws/observations/current?stationId=" + | |
station + | |
"&format=json&units=" + | |
units + | |
"&apiKey=" + | |
api_key; | |
const data = await this.makeApiCall(url); | |
return data.observations[0]; | |
} | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment