Created
April 30, 2021 20:30
-
-
Save NaveenDA/dd53dfa9c9ed5661cf1b42df80ea86b8 to your computer and use it in GitHub Desktop.
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
import { mutate } from 'swr' | |
function prefetch () { | |
mutate('/api/data', fetch('/api/data').then(res => res.json())) | |
// the second parameter is a Promise | |
// SWR will use the result when it resolves | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment