Skip to content

Instantly share code, notes, and snippets.

@NaveenDA
Created April 30, 2021 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NaveenDA/dd53dfa9c9ed5661cf1b42df80ea86b8 to your computer and use it in GitHub Desktop.
Save NaveenDA/dd53dfa9c9ed5661cf1b42df80ea86b8 to your computer and use it in GitHub Desktop.
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