-
My GitHub issue got moved into discussion, so I thought this would be a better location for this since it relates to the In the
const { data, error } = useSwr('/api/users', fetcher) be returning assigning anything to data or error?? Additional contextI am new to
In this example with data made on the same origin, I assume that However, with real API GET requests from a different origin, we require that the data is pulled using some data-fetching method. Assume we use native const url = 'https://api.somejson'
const liveData = fetch(url).then(res => res.json())
export default async (req, res) => {
res.json(liveData)
} Now, how do I consume this endpoint by using the const { data, error } = useSwr('/api/realUsers', fetcher) because I already have my |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
SWR falla your fetcher function passing the key as argument, in your case your URL is the key so your fetcher receives the URL from there. |
Beta Was this translation helpful? Give feedback.
SWR falla your fetcher function passing the key as argument, in your case your URL is the key so your fetcher receives the URL from there.