[英]Promise.then is not a function error only on server
I am running the below code on local which is working fine but on server I have this error:我在本地运行以下代码,运行正常,但在服务器上出现此错误:
Promise.then is not a function Promise.then 不是函数
let promise = null;
if (this.fileUrl) {
promise = this.pdfJS.getDocument(this.fileUrl);
}
else if (this.base64FileData) {
const pdfData = atob(this.base64FileData);
promise = this.pdfJS.getDocument({ data: pdfData });
}
console.log('pretty');
console.log(promise);
promise.then(function (docObj) {
console.log('promistest');
console.log(docObj);
this._loadingEnd();
this.renderPages(docObj);
}, this._onDocumentLoadError.bind(this)
);
The object returned by .getDocument
is not a promise, but it has a property called promise
.getDocument
返回的对象不是promise,但它有一个名为promise
的属性
therefore所以
let promise;
if (this.fileUrl) {
promise = this.pdfJS.getDocument(this.fileUrl).promise;
} else if (this.base64FileData) {
const pdfData = atob(this.base64FileData);
promise = this.pdfJS.getDocument({ data: pdfData }).promise;
} else {
promise = Promise.reject('invalid state');
// this will be handled by `this._onDocumentLoadError.bind(this)`
}
console.log('pretty');
console.log(promise);
promise.then(function (docObj) {
console.log('promistest');
console.log(docObj);
this._loadingEnd();
this.renderPages(docObj);
}, this._onDocumentLoadError.bind(this));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.