Skip to content

useSWR data returns undefined but I can see the data in the fetcher function #683

Answered by promer94
ksoenandar asked this question in Q&A
Discussion options

You must be logged in to vote
const fetcher = (url) => {
    return fetch(url)  **// You miss the return statement here**
        .then((r) => r.json())
        .then((data) => {
            console.log(data); <- returns data as expected
            return { user: data?.user || null };
        });
};

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
3 replies
@ksoenandar
Comment options

@sergiodxa
Comment options

@ksoenandar
Comment options

Comment options

You must be logged in to vote
2 replies
@sergiodxa
Comment options

@ksoenandar
Comment options

Answer selected by ksoenandar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants