I have the following url and a parameter :
number:200
"http://localhost:8000/textpath"
I want the path to be like this:
"http://localhost:8000/textpath/200"
How do I do that using Reactjs?I want to use the appended url in fetch method as follows:
fetch("http://localhost:8000/textpath/200")
A simple append did the work.Doesn't have to complicate
fetch("http://localhost:8000/textpath/"+number)
Try using Template literals.
const url = `http://localhost:8000/textpath/${number}`
fetch(url);
where number = 200
Refer here for more information
Related
I have written a code to update and delete with json and testing with postman it shows like below
here is my code
please give me a solution for this matter..
the req.params. should be the same like you write it in the path ("../:id")
so your code must be like this : let noticeId = req.params.id
or you change the path like this : router.route('/deleteNotice/:noticeId') and keeping this : let noticeId = req.params.noticeId
Could you show your routing
And after that, change your define noticeId to let noticeId = req.params.id
Because of you defined the route is /deleteNotice/:id with id is your params
I have a whois form that works with get query string and make results.
I want to redirect url from:
mysite.com/domain/google.com
to
mysite.com/domain?sld=google&tld=com
Thanks
In .htacees
For example try this --
Redirect /domain/google.com /domain?sld=google&tld=com
OR
Try this using through jquery for using any url
var baseurl = "mysite.com/domain/";
var a = window.location.pathname.split("/").pop();
var name = a.split(".")[0];
var name1 = a.split(".")[1];
alert(name);
alert(name1);
alert(baseurl+'?sld='+name+'&tld='+name1);
window.open(baseurl+'?sld='+name+'&tld='+name1);
Hope it will work for you
I have been looking at other websites and see when you search, primary something like a search term, location and category you will see a pretty url like:
example.com/black-boots/new-york/shoes
instead of what I have now which is something like:
example.com/search-results/search?=black+boots&city=new+york&category=shoes
In my route I could start with something like:
router.get('/search-results/:search/:city/:category', shopController.getSearchResults);
And in the controller I could use req.params.city and so on to get the values from the url but the part that I can't figure out is a good way to get the text input values into the url using a get request.
Using GET by default gives me the 'ugly' looking url.
Basically the part that needs to go into the form
<form method="GET" action="/search-results/search/city/category">
Comments, plus this code sample for a GET request:
const form = document.getElementById('searchform');
form.addEventListener('submit', evt => {
const who = encodeURIComponent(document.getElementById('who').value);
const where = encodeURIComponent(document.getElementById('where').value);
const what = encodeURIComponent(document.getElementById('what').value);
window.location.href = `/${who}/${where}/${what}`;
}
I want "value" from the following query string.
by doing request.query.filter i get the following
"[{\"property\":\"customerId\",\"value\":2,\"exactMatch\":true}]"
tried request.query.filter.value and request.query.filter["value"] but didn't work.
Request URL :
admin/api/login?action=get&_dc=1547652537836&filter=%5B%7B%22property%22%3A%22customerId%22%2C%22value%22%3A2%2C%22exactMatch%22%3Atrue%7D%5D
the query string seems to be a JSON string. so the first thing you have to do is convert it to json object to access it.
const query = "[{\"property\":\"customerId\",\"value\":2,\"exactMatch\":true}]";
const json = JSON.parse(query);
now you can access it with
json[0].value
I want to customize my URL rewriting but it seems not working as I'd like it to.
My old code :
var rewrite = require('express-urlrewrite');
exports.rewrite = function(app){
app.use(rewrite('/p/:id/:seoUrl', '/page/show/$1/$2'));
}
In my browser : http://mysite/p/1/seo-title (this URL works)
My new code :
var rewrite = require('express-urlrewrite');
exports.rewrite = function(app){
app.use(rewrite('/:seoUrl', '/page/show/$1/$2'));
}
In my browser : http://mysite/seo-title (ID not found)
Using NodeJS, is there a way to exclude the ID in the URL?
well. if you take a close look at this: '/page/show/$1/$2' you might notice that it accepts two arguments.
since you removed :id you'd have to replace $1 with a static id or remove it completely aswell as you have to change $2 to $1
so in the end your code might look like this: app.use(rewrite('/:seoUrl', '/page/show/1/$1'));
or like this: app.use(rewrite('/:seoUrl', '/page/show/$1'));