Skip to content

Instantly share code, notes, and snippets.

@timuckun
Created March 21, 2021 09:59
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 timuckun/dba4696755ebf350f1a32ad405e9c187 to your computer and use it in GitHub Desktop.
Save timuckun/dba4696755ebf350f1a32ad405e9c187 to your computer and use it in GitHub Desktop.
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