feat: ex Consuming pormises
This commit is contained in:
3190
package-lock.json
generated
3190
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,16 +1,58 @@
|
|||||||
import setText, {appendText, showWaiting, hideWaiting} from "./results.mjs";
|
import setText, { appendText, showWaiting, hideWaiting } from "./results.mjs";
|
||||||
|
|
||||||
export function get() {
|
export function get() {
|
||||||
|
axios.get("http://localhost:3000/orders/1")
|
||||||
|
.then(({ data }) => {
|
||||||
|
setText(JSON.stringify(data));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCatch() {
|
export function getCatch() {
|
||||||
|
axios.get("http://localhost:3000/orders/123")
|
||||||
|
.then(({ data }) => {
|
||||||
|
setText(JSON.stringify(data));
|
||||||
|
})
|
||||||
|
.catch(err => setText(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function chain() {
|
export function chain() {
|
||||||
|
axios.get("http://localhost:3000/orders/1")
|
||||||
|
.then(({ data }) => {
|
||||||
|
return axios.get(`http://localhost:3000/addresses/${data.shippingAddress}`);
|
||||||
|
})
|
||||||
|
.then(({data}) => {
|
||||||
|
setText(`City: ${data.city}`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function chainCatch() {
|
export function chainCatch() {
|
||||||
|
axios.get("http://localhost:3000/orders/1")
|
||||||
|
.then(({ data }) => {
|
||||||
|
axios.get(`http://localhost:3000/addresses/${data.shippingAddress}`);
|
||||||
|
})
|
||||||
|
.then(({data}) => {
|
||||||
|
setText(`City: ${data.city}`);
|
||||||
|
})
|
||||||
|
.catch(err => setText(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function final() {
|
export function final() {
|
||||||
|
|
||||||
|
showWaiting();
|
||||||
|
|
||||||
|
axios.get("http://localhost:3000/orders/1")
|
||||||
|
.then(({ data }) => {
|
||||||
|
return axios.get(`http://localhost:3000/addresses/${data.shippingAddress}`);
|
||||||
|
})
|
||||||
|
.then(({data}) => {
|
||||||
|
setText(`City: ${data.city}`);
|
||||||
|
})
|
||||||
|
.catch(err => setText(err))
|
||||||
|
.finally(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
hideWaiting();
|
||||||
|
}, 1500);
|
||||||
|
|
||||||
|
appendText(" -- Completely Done ");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user