传真API的Node.js Twilio HTTP检索失败

时间:2018-11-29 00:33:24

标签: javascript node.js twilio

我想设置通过twilio API接收传真。

这是我的index.js文件

// const http = require('http');
const express = require('express');
const bodyParser = require('body-parser');

const app = express();

// Parse any incoming POST parameters
app.use(bodyParser({ extended: false }));

var parentRef = admin.database().ref();

var updates ={};



 
app.post('/fax/received', (req, res) => {
  // log the URL of the PDF received in the fax
  console.log(req.body.MediaUrl);
  var faxData = req.body

  var faxContent = faxData.MediaUrl
  var faxSID = faxData.sid 
  var faxSender = faxData.from 
  var faxDate = faxData.date_created

  var senderdata = {

    FaxSender:faxSender,
    FaxURL:faxContent,
    FaxID:faxSID,
    
    date:Date.now(),
  };


       updates['/Fax/Recieved/' + faxSID] = senderdata;
        // updates['/Signups/Promoters/' + msgFrom] = senderdata;
       return parentRef.update(updates);

  // Respond with empty 200/OK to Twilio
  res.status(200);
  res.send();
});


http.createServer(app).listen(3000, () => {
   console.log('Express server listening on port 3000');
   });

当我尝试运行文件然后发送传真进行测试时 我不断收到此错误

  

11200-HTTP检索失败。

     

502错误的网关(在服务器日志上)

我怎么可能做错了

1 个答案:

答案 0 :(得分:0)

好像您只是返回一些值(return parentRef.update(updates);)而不发送任何内容给客户端。尝试评论return