'Multiply useQuery on one page, why undefined result?

I need too use useQuery a few times to get different data from db. So I call:

const {data: var1} = useQuery(MY_QUERY, {variable: {content1});

const {data: var2} = useQuery(MY_QUERY, {variable: {content2});

const {data: var3} = useQuery(MY_QUERY, {variable: {content3});

const {data: var4} = useQuery(MY_QUERY, {variable: {content4});

const {data: var5} = useQuery(MY_QUERY, {variable: {content5});

Still I can't get the result of useQuery (on backend (nest.js) I see correct response in console, but cant see it on frontend(react.js))

Help me, please. I am missed something



Solution 1:[1]

I see 3 syntax errors that may be the problem, first you probably need a space between const and {data... and variable should be a plural variables. also you are missing a curly bracket inside useQuery

Try this?

const { data: var1 } = useQuery(MY_QUERY, { variables: { content1 } });

console.log(var1)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 rymanso