Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useSWR data type #5

Open
RomainGuarinoni opened this issue Jan 18, 2022 · 1 comment
Open

useSWR data type #5

RomainGuarinoni opened this issue Jan 18, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@RomainGuarinoni
Copy link
Collaborator

RomainGuarinoni commented Jan 18, 2022

I find weird that the data return from useSWR this :

config: {transitional: {…}, transformRequest: Array(1), transformResponse: Array(1), timeout: 0, adapter: ƒ, …}
data: {nbMusician: 3, nbGroups: 2, nbEvents: 1}
headers: {content-length: '42', content-type: 'application/json; charset=utf-8'}
request: XMLHttpRequest {onreadystatechange: null, readyState: 4, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, …}
status: 200
statusText: "OK"
[[Prototype]]: Object

it should be only the data from that type :

type data: {
    nbMusician: number;
    nbGroups: number;
    nbEvents: number;
  };
@RomainGuarinoni RomainGuarinoni added the bug Something isn't working label Jan 18, 2022
@RomainGuarinoni
Copy link
Collaborator Author

We need to do like this :

const { data: musiciansList, error } = useSWR('/musicians', (url) =>
    authAxios.get(url).then((res) => res.data),
  );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant