Tag: Promise

Understand “Promise” (3/3): Create a Simple “Axios”

In previous post, I used some Pseudo code in Promise constructor, now I will create a Promise instance with real code, and for better understanding, I will use JQuery to do ajax call. Step 1: the origin is axios.get(url), it looks like some instance call its function, so I will start with creating our own …

Understand “Promise” (2/3): Promise Instance

Step 1: In previous post, the result of axios.get(“/api/items”) is a Promise instance. Step 2: But the original way to create a Promise instance is using Promise constructor. Step 3: We now can use “myPromise” to call .then() or .catch() Step 4: Only if resolve() is executed in step 2, then() in step 3 will …

Understand “Promise” (1/3): Axios

Step 0: I assume you have already read some documents and confusing now. Also, I assume you have already known how to use “axios”. Step 1: If you don’t understand “Promise”, start from “axios”. Step 2: But before that, you need to know “Promise” is a class. Step 3: Then “axios” is based on “Promise”, …