Answer the question
In order to leave comments, you need to log in
What does this line of code mean?
Confused by __regex and axios.get(`${API_URL}?sort=-createdAt${search}`)
Are regular expressions that weird?
https://learn.javascript.ru/regular-expressions-ja... reading about reg. expressions did not help to understand what was happening. I understand that they are passing a variable to the server in order to write it to the database
export const search = () => {
return (dispatch, getState) => {
const description2 = getState().todo.description2;
const search = (description2) ? `&description2__regex=/${description2}/` : '';
axios.get(`${API_URL}?sort=-createdAt${search}`)
.then((res) => dispatch({type: 'TODO_SEARCHED', payload: res.data}));
};
};
Answer the question
In order to leave comments, you need to log in
Optionally, a regular expression is added to the query string of the request, available via the description2__regex key .
If the question is only about syntax, then template strings are used .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question