意外的identifierFlow(ParseError)

时间:2019-06-13 12:46:04

标签: reactjs react-native

我已经创建了这个localStorage.js

import { AsyncStorage } from 'react-native';

const storageSet = async (key, value) => {
    try {
        await AsyncStorage.setItem(key, value);
    } catch (error) {
        console.log(error);
    }
}

const storageGet = async (key) => {
    try {
        const result = await AsyncStorage.getItem(key);
        console.log(result);
        return result;
    } catch (error) {
        console.log(error);
    }
}

export { storageSet, storageGet };

使用

import { storageGet } from "./localStorage";

const value = await storageGet('language');

我收到语法错误Unexpected identifierFlow(ParseError)。如果我删除等待我得到的承诺。如何获得价值而不是承诺?

0 个答案:

没有答案