I have a react/typescript application made of client and server. The client asks the server for some data and proceeds to show it with React.
On the client side, when asking for data, I do:
export const createApiClient = (): ApiClient => {
return {
getTickets: () =>
return axios.get(APIRootPath).then((res) => res.data);
}
}
}
On the server-side, sending data, I do:
app.get(APIPath, (req, res) => { // @ts-ignore
const page: number = req.query.page || 1;
const paginatedData = tempData.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE);
res.send(paginatedData);
});
Now, I was asked to do the following:
- Add a query param ?search= to the /tickets API call and implement it on the server-side.
- Connect your client-side search bar to that API call
I understand that the server, before sending the data back, should filter it by some string 'x'
, which gets inputted on the search bar.
What I don't understand from the question (and since I'm not familiar with web development at all), is how the server should receive this string.
Assuming that I was already able to connect the search bar in a way that shows the input on the URL. How would I send this parameter to the server? Do I even have to send it? Or should I be able from the server to extract the parameter myself?
Thank you for the help