Reputation: 7083
I have passed two params from client to express endpoint it gives me results on my local machine but when i deploy to linux server its not working no errors and no response ? Do you think it could be params issue ?
client.js
getServerSearch:function(str,strEnv){
return $http.get("/serverSearch?searchTxt=" + str + '&searchEnv=' + strEnv);
}
server.js
app.get('/serverSearch', function (req, res) {
var searchTxt = req.query.searchTxt;
var searchEnv = req.query.searchEnv;
searchFileService.readFile(searchTxt,searchEnv,function(lines,err){
console.log('Logs',lines);
if (err)
return res.send();
res.json(lines);
});
console.log('Search text', searchTxt);
})
;
Upvotes: 0
Views: 455
Reputation: 48968
Certain ASCII characters and unicode points larger than 127 need to be properly encoded in UTF-8 and replaced with percent-encoding.
The AngularJS $http service has a built-in param serializer to do that.
function getServerSearch(str,strEnv){
//return $http.get("/serverSearch?searchTxt=" + str + '&searchEnv=' + strEnv);
var params = {};
params.searchTxt = str;
params.searchEnv = strEnv;
return $http.get("/serverSearch", { params: params })
.catch(function(errorResponse) {
console.log(errorResponse);
throw errorResponse;
});
}
Also it is wise to include a rejection handler to see any internal framework errors or errors returned from the server.
Also see MDN JavaScript reference - encodeURIComponent().
Upvotes: 1