Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

swr data fetching

import useSWR from 'swr'

function Profile() {
  const { data, error } = useSWR('/api/user', fetcher)

  if (error) return <div>failed to load</div>
  if (!data) return <div>loading...</div>
  return <div>hello {data.name}!</div>
}
Source by www.npmjs.com #
 
PREVIOUS NEXT
Tagged: #swr #data #fetching
ADD COMMENT
Topic
Name
2+1 =