TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be one of type string, Buffer, TypedArray, or DataView. Received type undefined

发布时间:2020-05-19编辑:佚名阅读(6474)

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be one of type string, Buffer, TypedArray, or DataView. Received type undefined

原因:

Node后端 express框架,代码如下:

app.get(path, function(req, resp) {
  // ...
  resp.write(somethind);
});

要写回浏览器页面的数据something的类型不是string或Buffer(可能是一个对象)。
转换类型即可:

resp.write(JSON.stringify(something));

将something对象字符串化。

    关键字: TypeError ERR_INVALID_ARG_TYPE The data argument must be one of type string Buffer TypedArray or DataView Received type undefined


鼓掌

5

正能量

2

2

呵呵

7


评论区