【发布时间】:2020-05-13 12:16:38
【问题描述】:
我是谷歌云功能和 Node Js 的新手,当我尝试解析 Json 有效负载时不断收到此错误
exports.processdata = (event, context) => {
const pubsubMessage = event;
var obj = JSON.parse(Buffer.from(pubsubMessage.data, 'base64').toString());
console.log(obj.temp);
};
错误
TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.
Function.Buffer.from
CLoud 函数在 Node.Js 版本 8 上运行
【问题讨论】:
-
从错误中可以看出,您收到了您的第一个参数,我想您在代码示例中附加的“事件”应该是字符串、缓冲区、ArrayBuffer、数组或类似数组的基本上告诉你,你需要将它定义为其中之一。
标签: node.js google-cloud-functions google-cloud-pubsub