等待我有问题,巴贝尔38年5月8日,等待中的Node.js 我的代码看起来像:巴贝尔38年8月5日无视Node.js的
/**
* Imports
*/
import {signature} from '../core/antpool';
import log from '../core/logging';
import config from '../config';
import {sendLog as sendEmailLog, EmailTemplate} from '../core/email';
import {rethinkdb, Decorators as DBDecorators} from '../core/db';
import request from 'request';
const tables = {
AntpoolAccount: 'CronAntpoolAccount'
};
class Antpool {
@DBDecorators.table(tables.AntpoolAccount)
static async account(coin) {
var nonce = Date.now();
request.post({
url: config.antpool.baseUrl + '/api/account.htm',
json: true,
form: {
key: config.antpool.key,
nonce: nonce,
signature: signature(nonce),
coin: coin
}
}, function (err, httpResponse, body) {
if (err || httpResponse.statusCode != 201) {
log.error(err, '[CRON][Antpool][Account] Connection problem');
sendEmailLog(EmailTemplate.LOG, {
message: '[CRON][Antpool][Account] Connection problem'
});
return false;
}
var out = JSON.parse(body);
if (out.code != 0) {
log.error(err, '[CRON][Antpool][Account] Error response('+out.code+'): '+out.message);
sendEmailLog(EmailTemplate.LOG, {
message: '[CRON][Antpool][Account] Error response('+out.code+'): '+out.message
});
return false;
}
// Add to database
let obj = {
earn24: out.data.earn24Hours,
earnTot: out.data.earnTotal,
paidOut: out.data.paidOut,
balance: out.data.balance,
createdAt: new Date()
};
// Insert into database
let insert = await this.table.insert(obj).run();
if(insert) {
return true;
} else {
return false;
}
});
}
}
/**
* Exports
*/
export {Antpool};
我所得到的只是错误,有问题等待。
SyntaxError: .../antpool.js: Unexpected token (59:22)
// Insert into database
let insert = await this.table.insert(obj).run();
我在想什么可以解决方案接受等待。这是不是很奇怪,因为在代码的其他部分等待运作良好。 不确定究竟是什么问题,但花了大约两天才发现问题。
我打电话的脚本有:
/**
* Automatically hook babel into all node requires.
*/
require('babel/register')({
optional: ['es7.asyncFunctions', 'es7.classProperties', 'es7.decorators']
});
/**
* Start application worker.
*/
require('./src/worker');
任何帮助是非常赞赏。
您正在使用的函数中等待“功能(ERR,HttpResponse对象,型)”未署名为异步 –