i have function uses textract (https://www.npmjs.com/package/textract).
$scope.textract = function(fileurl) { var req = { method: 'get', url: 'http://localhost:3000/textract', params: { fileurl: fileurl } }; $http(req) .success(function(status, data) { console.log('status is: ' + status); console.log('data is: ' + data); }) .error(function(status, response) { console.log('error status is: ' + status); console.log('error response is' + response); }); }; on express server, have:
function countwords(text) { var s = text ? text.split(/\s+/) : 0; // splits text on space/tab/enter return s ? s.length : ''; } app.get('/textract', function(req, res, next) { filepath = path + req.query.fileurl; textract(filepath, function(error, text) { if (!error) { console.log(text); return res.status(200).send(countwords(text)); } else { return res.sendstatus(400); }; }); }); on server, console.log(text) , countwords(text) work.
question: on client, $http prints on .error, in other words, it's not passing on .success (which believe should do, because on server word counter working ok).
any ideas?
Comments
Post a Comment