TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be one of type string or Buffer.

港控/mmm° 2022-01-10 02:21 446阅读 0赞

Msg

TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be one of type string or Buffer. Received type object

原因:

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

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

要写回浏览器页面的数据something的类型不是stringBuffer(可能是一个对象)。
转换类型即可:
resp.write(JSON.stringify(something));
something对象字符串化。

发表评论

表情:
评论列表 (有 0 条评论,446人围观)

还没有评论,来说两句吧...

相关阅读