http传出值的类型错误.replace不是函数

时间:2015-07-15 15:34:18

标签: javascript node.js http replace

我在删除数据库中的内容并探索路径后发生此随机节点错误。这是由什么引起的?

_http_outgoing.js:299
    value = value.replace(/[\r\n]+[ \t]*/g, '');
                  ^
TypeError: value.replace is not a function
    at storeHeader (_http_outgoing.js:299:19)
    at ClientRequest.OutgoingMessage._storeHeader (_http_outgoing.js:215:9)
    at ClientRequest._implicitHeader (_http_client.js:166:8)
    at ClientRequest.OutgoingMessage.end (_http_outgoing.js:539:10)
    at Request.end (/Users/thomas/Desktop/node-project-app/node-project-api/node_modules/request-promise/node_modules/request/request.js:1363:12)
    at end (/Users/thomas/Desktop/node-project-app/node-project-api/node_modules/request-promise/node_modules/request/request.js:563:14)
    at Immediate._onImmediate (/Users/thomas/Desktop/node-project-app/node-project-api/node_modules/request-promise/node_modules/request/request.js:577:7)
    at processImmediate [as _immediateCallback] (timers.js:371:17)
15 Jul 11:26:54 - [nodemon] app crashed - waiting for file changes before starting...

1 个答案:

答案 0 :(得分:0)

我认为当您将request(在我的情况下为request-promise)参数(在我的案例标题中)设置为函数而不是字符串时,会导致此错误。