Get Parameters From Node Js From External Website
I have create a nodejs server which will give response as ip address app.get('/UserIP', function(req, res) { console.log(req.connection.remoteAddress); res.send(JSON.stringif
Solution 1:
- If you have
app.set('case sensitive routing', true);
in your app , accessing "/userip" instead of "/UserIP" will not work. You haveapp.get('/UserIP'
and$.getJSON("http://localhost:7979/userip"
. - In your jQuery code , you are accessing a "res" Object
+ res.ip)
, even though you are returning a "data"function (data)
Object.
Solution 2:
The reason I am not able to get json is due to permitions.To fix this we need to fix it write this code in apt.get
res.setHeader("Access-Control-Allow-Origin", "*");
No other solution helped me.any way thanks for trying to help me.
Post a Comment for "Get Parameters From Node Js From External Website"