-
-
Save xnimorz/5a2783da12e8e31b8fb0c02a8064f5a7 to your computer and use it in GitHub Desktop.
fetch data example
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
... | |
if (action.type !== LOCATION_CHANGE) { | |
return; | |
} | |
const route = getRoute(action.payload.pathname); | |
try { | |
const [result] = await Promise.all([ | |
fetcher.getPage(parsedUrl.pathname, { params: parsedUrl.params }), | |
route.component.preload() | |
]); | |
} catch (e) { | |
processError(e); | |
return; | |
} | |
injectData(result); | |
return result; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment