Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4
Time To Code oh you mean search paramaters but by your questions it seemd like you are trying to do something with url paths i myself had used search paramaters in my sololearn code previewer its machemism is simple just look for the specific params when page loads and according to that you can perform actions here's an article by Google devs https://developers.google.com/web/updates/2016/01/urlsearchparams
25th Nov 2021, 2:26 PM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 6
it seems you trying to build an api you may use nodejs for that this may help you https://medium.com/@onejohi/building-a-simple-rest-api-with-nodejs-and-express-da6273ed7ca9 u can use url params to get the name of the country
25th Nov 2021, 2:13 PM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 3
yes Time To Code you can do that with nodejs read the article you'll get it instead of json data you can just return an html page
25th Nov 2021, 2:20 PM
Arnav Kumar [Less/Not Active]
Arnav Kumar [Less/Not Active] - avatar
+ 2
Time To Code I think PHP and Node.js can help you a lot
25th Nov 2021, 2:14 PM
Pariket Thakur
Pariket Thakur - avatar
+ 2
To handle urls and show a 404 for exmple, you need a javascript URL router. There are many frameworks and libraries which you can use. Like: react, angular, vue, etc. Or you can install url-router using npm: url-router -npm. If you don't want to use any of those, then you can create your own url router. or you can build something simple like this: const pages =["india","germany","belgium","albania",....]; then use: const page = pages.find(c=> window.location.protocol +"/"+window.location.host+window.location.pathname.lastIndexOf(c)>-1); if(page == undefined){ //REDIRECT TO PAGE NOT FOUND } I would still advice to use a router framework or library for js.
27th Nov 2021, 9:42 AM
Imir Hoxha
Imir Hoxha - avatar
0
Location.Search is used to search a part of the url. IndexOf can be used as well to look for 1 to many chars in a string.
27th Nov 2021, 9:45 AM
Imir Hoxha
Imir Hoxha - avatar
- 3
add tag img in the html.
28th Nov 2021, 10:47 AM
Shubham Bhatia
Shubham Bhatia - avatar