mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-06 23:43:45 +02:00
content(resources): update/tweak JS promises resources
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
---
|
||||
authors:
|
||||
- "Xetera#0001"
|
||||
- "veksen#1060"
|
||||
created_at: 2019/07/26
|
||||
updated_at: 2019/07/26
|
||||
updated_at: 2020/05/20
|
||||
title: Introduction to Promises
|
||||
recommended_reading:
|
||||
- javascript/callbacks/intro
|
||||
@@ -85,6 +86,14 @@ getWeather("Los Angeles").then((weather) => {
|
||||
});
|
||||
```
|
||||
|
||||
Outlining this one again, because it's very common, is to attempt to use the value of a promise, but not resolving it:
|
||||
|
||||
```js
|
||||
// Incorrect code, don't copy!
|
||||
const weather = getWeather("Los Angeles");
|
||||
console.log(weather); // Promise {<pending>}
|
||||
```
|
||||
|
||||
## Real World Example
|
||||
|
||||
Here is a real function that gets character information from the Rick and Morty API.
|
||||
|
||||
Reference in New Issue
Block a user