我正在运行一个带有一些云函数的 Parse Server 实例,我想在其中一个函数中从另一个 API 获取 JSON 内容。
在处理 JSON 之前,我希望能够以字符串形式获取结果,以确保我确实获取了这些数据。这是我尝试过的:
const got = require('got');
Parse.Cloud.define(
"cloudTestFunction",
async (request) => {
const query = new Parse.Query("MyParseClass");
// skipping the lines where I build the query
const results = await query.find();
const firstResult = results[0];
if (firstResult == null) {
// here I want to get data from another API
const text = await got(apiURL).text();
return text;
} else {
return 'result found';
// return firstResult;
}
}
);
但是这样做,我在这里收到一条错误消息:
▿ ParseError code=141 error=got(...).text is not a function
- 代码:ParseSwift.ParseError.Code.scriptFailed
- 消息:“得到(...)。文本不是函数”
- 其他代码:无
- 错误:无
这可能是什么原因?
谢谢你的帮助