在更新到Meteor 1.2.1和角度1.2.0之后我m have error while build application: "ReferenceError: Promise is not defined". Before update i
m使用ecmascript作为es6,在更新新软件包之后:angular-babel和我看到两个软件包之间的冲突 - ecmascript和angular-巴贝尔。删除ecmascript后我有一个错误......我怎么能解决这个问题?
承诺使用样本:
CSMS = class CSMS {
constructor() {
return true;
}
createCheckCode(phoneNumber) {
var codeBlocks = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
var checkCode = '';
for (var i = 0; i<=5; i++) checkCode += Random.choice(codeBlocks);
return new Promise(function(resolve, reject) {
HTTP.call("GET", Meteor.settings.private.smsAPIPath,
{
params: {
login: Meteor.settings.private.smsAPILogin,
psw: CryptoJS.MD5(Meteor.settings.private.smsAPIPass).toString(),
phones: phoneNumber,
mes: '"Близкие люди". Код подтверждения: ' + checkCode,
charset: 'utf-8',
fmt: 3,
cost: 2
}
}, function(err, res) {
if (err) reject(err);
else {
if (res.statusCode == 200) {
resolve({"sms":res.content, "code":checkCode});
} else reject(res);
}
});
});
}
}
使用样本分类:
var sms = new CSMS();
sms.createCheckCode('+79384225547').then(
function(res) {
console.log("SMS Sended: ", res);
},
function(err) {
console.log("SMS Error:", err);
});
答案 0 :(得分:1)
问题解决了。
meteor add promise