【发布时间】:2019-09-28 11:49:12
【问题描述】:
所以我目前正在尝试返回我从承诺中获得的值。返回的数据是一个数组,我需要遍历它以从某个条件中获取正确的值。这是代码。
const currency = await getCurrency().then(({ data }) => {
data.map(({ default, code }) => {
if (default){
return code
}
})
}
return { pageProps, categories, currency };
}
按照要求,getCurrency 代码
export const getCurrency = () => Moltin.Currencies.All();
我大约 98% 确定我的问题来自语法! 感谢您的帮助
【问题讨论】:
-
请添加
getCurrency()的代码 -
@Vencovsky 我添加了代码。
-
您遇到错误了吗?
-
@Vencovsky 意外关键字“默认”
-
默认是javascript中的保留字,修改变量名。