Fixing logic to return reject in promise
This commit is contained in:
parent
fdf0129e5d
commit
a0af3ff5d9
|
@ -231,14 +231,15 @@ EmbarkJS.Storage.IPFS = {
|
||||||
|
|
||||||
EmbarkJS.Storage.connect = function(provider){
|
EmbarkJS.Storage.connect = function(provider){
|
||||||
var self = this;
|
var self = this;
|
||||||
if (provider.toLowerCase() === EmbarkJS.Storage.Providers.IPFS) {
|
var promise = new Promise(function(resolve, reject) {
|
||||||
var promise = new Promise(function(resolve, reject) {
|
if (provider.toLowerCase() === EmbarkJS.Storage.Providers.IPFS) {
|
||||||
resolve(self.currentStorage.ipfsConnection);
|
resolve(self.currentStorage.ipfsConnection);
|
||||||
});
|
}
|
||||||
}
|
else {
|
||||||
else {
|
var error = new Error(provider + ' storage provider not supported');
|
||||||
reject('Storage provider not supported');
|
reject(error);
|
||||||
}
|
};
|
||||||
|
});
|
||||||
|
|
||||||
return promise;
|
return promise;
|
||||||
};
|
};
|
||||||
|
|
17
js/embark.js
17
js/embark.js
|
@ -158,14 +158,15 @@ EmbarkJS.Storage.IPFS = {
|
||||||
|
|
||||||
EmbarkJS.Storage.connect = function(provider){
|
EmbarkJS.Storage.connect = function(provider){
|
||||||
var self = this;
|
var self = this;
|
||||||
if (provider.toLowerCase() === EmbarkJS.Storage.Providers.IPFS) {
|
var promise = new Promise(function(resolve, reject) {
|
||||||
var promise = new Promise(function(resolve, reject) {
|
if (provider.toLowerCase() === EmbarkJS.Storage.Providers.IPFS) {
|
||||||
resolve(self.currentStorage.ipfsConnection);
|
resolve(self.currentStorage.ipfsConnection);
|
||||||
});
|
}
|
||||||
}
|
else {
|
||||||
else {
|
var error = new Error(provider + ' storage provider not supported');
|
||||||
reject('Storage provider not supported');
|
reject(error);
|
||||||
}
|
};
|
||||||
|
});
|
||||||
|
|
||||||
return promise;
|
return promise;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue