SWR Fetcher

Fetcher is a function used for SWR library

––– views

Used for SWR library

Code

// utils/fetcher.js
export default async function fetcher(...args) {
const res = await fetch(...args);
return res.json();
}
js

How To Use

const { data } = useSWR('/api/spotify', fetcher);
jsx