I have a simple expressjs
script like:
var app = require('express')();
var http = require('http').Server(app);
var requestAuth = function (req, res, next) {
var xhr = new XMLHttpRequest()
console.log("a", xhr)
next()
}
app.use(requestAuth)
app.get('/', function(req, res){
res.send('<h1>Hello again</h1>');
});
http.listen(3000, function(){
console.log('listening on *:3000');
});
Here I want to make simple ajax call and check for authentication in url.
Whhen I execuste the above script it gives me error like XMLHttpRequest
is not defined. What is the issue here ?
Same type of error I got when I tried using promise
How can I make http request using xhr or fetch ?
Isnt it nodejs should accept all the functions that normal javascript accept ?
Can anyone make me more clear ? I am very new to expressjs
via aryan
No comments:
Post a Comment