我使用back4app作为后端服务来部署我的应用程序,它是在中开发的。我正在测试如何使用back4app的“云代码函数”.
由于我是back4app的初学者,我在使用他们的指南时发现了一个问题。我面临这样的消息错误:'async functions' is only available in ES8 (use 'esversion: 8').
Back4app侧:
import Parse from 'parse/react-native.js';
import AsyncStorage from '@react-native-async-storage/async-storage';
//Initializing the SDK
Parse.setAsyncStorage(AsyncStorage);
//Paste below the Back4App Application ID AND the JavaScript KEY
Parse.initialize('YOUR_APPLICATION_ID_HERE', 'YOUR_JAVASCRIPT_KEY_HERE');
//Point to Back4App Parse API address
Parse.serverURL = 'https://parseapi.back4app.com/';
//This is a hello function and will log a message on the console
Parse.Cloud.define("hello", async (request) => {
console.log("Hello from Cloud Code!");
return "Hello from Cloud Code!";
});我的应用程序:
const helloFunction = await Parse.Cloud.run("hello");我知道问题来自异步函数,但我找不到任何解决方案。我做错了什么?
发布于 2021-12-02 12:43:33
当使用云代码时,您不需要进行任何类型的初始化,因为它已经在Back4app服务器上完成了。
因此,在您的main.js文件中,请删除:
发布于 2021-12-14 19:02:42
要真正回答这个问题,错误信息是一个假阳性!可能在线编辑器配置不正确,所以它意外地显示了这些警告.
正如指南告诉您的,如果运行3.xParseServer,可以使用async关键字。使用它应该是安全的,因为默认使用的是ParseServer4.x(服务器可以通过> Settings >进行更改)。
https://stackoverflow.com/questions/70197799
复制相似问题