Last active
May 11, 2017 03:59
-
-
Save watanabeyu/c57df92555ba18905c253658007e1607 to your computer and use it in GitHub Desktop.
ssrでfetchしてるときにあえてsetTimeout使って遅らせたいときの、setTimeoutの書き方
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
return new fetch(`/hogehoge`) | |
.then(response => { | |
return response.json().then(json => ({ status: response.status, json })) | |
}) | |
.then(r => { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
console.log("settimeout finish") | |
resolve(0) | |
return dispatch({ type: "FINISH" }) | |
}, 5000) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment