1

I'm trying to make a request to the API with some specific parameters (in this case, userName and listId).

What comes to my mind first is the following:

const { userName, listId } = useParams();
const list = useQuery(["lists"], api.fetchList(userName, listId)); // This line is incorrect

Inside my API file, I'm doing something like this:

export const fetchList = async (userName, listId) =>
api.get(`/list/${userName}/${listId}`).then((res) => res.data);

how is it possible to actually achieve this?

4

1 Answer 1

1

I found the solution.

When we are passing parameters, we will have to write this the following way:

const list = useQuery(["lists"], () => api.fetchList(listId));

(I had to remove userId since it's not necessary for my API).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.