【发布时间】:2019-04-18 04:54:54
【问题描述】:
我在 nodejs 中创建了一个类
class ApnService {
sendNotification(deviceType, deviceToken, msg, type, id) {
try {
const note = await apnProvider.send(note, deviceToken)
console.log(note)
} catch (err) {
console.log(err)
}
}
}
export default ApnService
我需要做的是将上述函数转换为async。但是当我使用下面的语法时它会抛出错误
SyntaxError: src/services/apn.js: Unexpected token (43:19)
41 | }
42 |
> 43 | sendNotification = async(deviceType, deviceToken, msg, type, id) => {
|
^
下面是语法
class ApnService {
sendNotification = async(deviceType, deviceToken, msg, type, id) => {
try {
const note = await apnProvider.send(note, deviceToken)
console.log(note)
} catch (err) {
console.log(err)
}
}
}
export default ApnService
【问题讨论】:
标签: javascript node.js asynchronous async-await ecmascript-2017