Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. app.post('/predixcall', function(req, res){
  2.  
  3. var list = req.body.list;
  4. var id= req.body.vesselId;
  5.  
  6. var requestInfo = {
  7. tags: []
  8. };
  9.  
  10.  
  11. for(var i = 0; i < list.length; i++){
  12. requestInfo.tags.push({
  13. "name": list[i],
  14. "filters": {
  15. "attributes": {
  16. "id": id
  17. }
  18. },
  19. "order": "asc"
  20. });
  21. }
  22.  
  23. request.post({
  24. uri:'http://localhost:3000/api',
  25. headers:{
  26. 'Content-Type': 'application/text; charset=utf-8'
  27. },
  28. body: JSON.stringify(requestInfo)
  29. },function (error, response, body) {
  30. console.log('Error is ', error);
  31. res.send(JSON.parse(response.body));
  32. }
  33. );
  34. });
  35.  
  36. Error is undefined { Error: Parse Error
  37. at Error (native)
  38. at Socket.socketOnData (_http_client.js:363:20)
  39. at emitOne (events.js:96:13)
  40. at Socket.emit (events.js:188:7)
  41. at readableAddChunk (_stream_readable.js:176:18)
  42. at Socket.Readable.push (_stream_readable.js:134:10)
  43. at TCP.onread (net.js:548:20) bytesParsed: 754, code: 'HPE_UNEXPECTED_CONTEN
  44. T_LENGTH' }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement