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).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.