but how do i send that data to the back-end?
Like you said, with fetch or some other tool.
I understand that i have to use fetch for that or in my case axios since im using React.
I’ve used both with React, I’ve used both when not using React. I know of no reason why you couldn’t use fetch with React - that is actually what I usually use. If you want to use axios, that’s fine, but not because you have to.
what http type would be the best for that and how do i code that?
Remember that the names of the methods and what they are associated with are just arbitrary. (I once had an interview where they asked me if I could delete a record with a GET request. I told them that it might be confusing to the next coder, but it could be done. They were relieved to hear that as they said 90% of the people said it could only be done with a DELETE request. I still didn’t get the job.)
So, semantically, a GET makes the most sense - you can pass in parameters with that and you are doing what GET is made to do - retrieve information. The only exception would be if there is a lot of information that needs to be passed (like if you didn’t need to pass the search words but the entire text) - one of the disadvantages of GET is that you can’t pass a body. In cases like that, I’ve seen people use POST when really what they’re doing would make more sense with GET.
I know when I use have to look up a single product we can use the GET method with a id at the end of the url.
You can send anything thing you want in a GET request url, in one or many parameters, and any data that can be serialized into a URL friendly string.
but how do we achive that with multiple filter words like: TitleName, PriceMin, PriceMax??
There are a lot of ways to do this. The simplest would be something like:
Or if you want, you can put them all in an object, stringify that object, and then base 64 encode it and just send it as:
That is easy to do and easy to decode in the server.
Does that all make sense? There may be some other possibilities , but that is an approach.