How to use the es6-promise.reject function in es6-promise

To help you get started, we’ve selected a few es6-promise examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github podio / podio-js / test / push.spec.js View on Github external
it ('should reject if authentication has not been performed', function(done) {

      var host = {
        _getAuth: sinon.stub().returns({
          isAuthenticated: sinon.stub().returns(Promise.reject())
        })
      };
      
      var options = {
        timestamp: 1435054283,
        expires_in: 21600,
        channel: "/conversation/2256621",
        signature: "7d2018df16bd7686063483c8960124bc0a1bb0e2"
      };

      var subscription = pushLib.push.call(host, options).subscribe(new Function());

      subscription.then(function(){
        // Should not be called
        expect('Authentication should not pass').toBe(false);
      }).catch(function(err) {
github joaocarvalhowd / finducep.js / src / FindUCep.js View on Github external
find(cep) {
    if (this.validateCep(cep)) {
      return this.webMania(cep)
                .catch(() => this.viaCep(cep));
    }

    return Promise.reject(false);
  }
github joaocarvalhowd / finducep.js / src / FindUCep.js View on Github external
handleWebmania(response) {
    if (response.data.uf === '') {
      return Promise.reject('CEP não encontrado');
    }

    let data = response.data;
    const estado = this.getState(data.uf);

    data = Object.assign({}, data, { estado });

    return data;
  }
github joaocarvalhowd / finducep.js / src / FindUCep.js View on Github external
handleViaCep(response) {
    const data = response.data;

    if (response.status !== 200 || data.erro) {
      return Promise.reject('CEP não encontrado');
    }

    const estado = this.getState(data.uf);

    return {
      cep: data.cep,
      endereco: data.logradouro,
      bairro: data.bairro,
      cidade: data.localidade,
      estado,
      uf: data.uf,
    };
  }
github joaocarvalhowd / finducep.js / src / FindUCep.js View on Github external
handleError() {
    return Promise.reject('CEP não encontrado');
  }