I am just staring react now and I am reading about queries. I have learned to search for countries but I do not know operations to be more specific.
https://somesite…./api?search=N
Returns me all the countries that has N in its name, but I want to find countries that starts with N, any ideas?
Tried with n and ^n
2
Answers
Please be more specific… are gou working with some api?
If yes provide the api… or you are building your own?
Way 1:
You need to check in API documentation for the same, whether they is any way to finding countries that start with a particular letter.
Way 2:
=> Store the API response in one state and filter the result using startsWith() method in JavaScript. Here is the example:
Use filter while saving the data.
Let me know, if you have any doubts.