Answer the question
In order to leave comments, you need to log in
What is the correct way to call action in Ract Redux?
There is a url filter on the back: "/list/?genres=&page=&search=&favorite=&ordering="
Should I add all the parameters to the action url at once or would it be better to do something else?
export const get = (genre, page, search, favorite, ordering) => (
dispatch
) => {
const url = `${API_URL}/list/?genres=${genre}&page=${page}&search=${search}&favorite=${favorite}&ordering=${ordering}`;
axios
.get(url)
.then((res) => {
dispatch({
type: GET,
payload: res.data,
});
})
.catch((err) => console.log(err));
};
Answer the question
In order to leave comments, you need to log in
Yep, just like this
const params = { search: 3 }; // условно, тут все ваши параметры
axios
.get(url, params)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question