Tabnine Logo For Javascript
Promise.then
Code IndexAdd Tabnine to your IDE (free)

How to use
then
function
in
Promise

Best JavaScript code snippets using builtins.Promise.then(Showing top 15 results out of 72,882)

origin: asciidwango/js-primer

function fetchUserInfo(userId) {
  return fetch(`https://api.github.com/users/${encodeURIComponent(userId)}`)
    .then(response => {
      if (!response.ok) {
        return Promise.reject(new Error(`${response.status}: ${response.statusText}`));
      } else {
        return response.json();
      }
    });
}
origin: asciidwango/js-primer

describe(URL, function() {
  it("ロードするとログが表示される", function() {
    visitWithConsole(URL).then(({ logSpy }) => {
      expect(logSpy).to.be.calledWith("index.js: loaded");
    });
  });
});
origin: cube-js/cube.js

export function unregister() {
 if ('serviceWorker' in navigator) {
  navigator.serviceWorker.ready
   .then(registration => {
    registration.unregister();
   })
   .catch(error => {
    console.error(error.message);
   });
 }
}
origin: cteamx/Thief

// Install `vue-devtools`
require('electron').app.on('ready', () => {
 let installExtension = require('electron-devtools-installer')
 installExtension.default(installExtension.VUEJS_DEVTOOLS)
  .then(() => {})
  .catch(err => {
   console.log('Unable to install `vue-devtools`: \n', err)
  })
})
origin: cube-js/cube.js

function runQueryTest(q, expectedResult) {
  return compiler.compile().then(() => {
   const query = dbRunner.newQuery({ joinGraph, cubeEvaluator, compiler }, q);

   logSqlAndParams(query);

   return dbRunner.testQuery(query.buildSqlAndParams()).then(res => {
    debugLog(JSON.stringify(res));
    res.should.be.deepEqual(
     expectedResult
    );
   });
  });
 }
origin: facundoolano/google-play-scraper

it('should fetch PriceText for paid apps properly', () => {
  return gplay.app({ appId: 'com.teslacoilsw.launcher.prime', country: 'in' })
   .then((app) => {
    assert.equal(app.priceText, `₹${app.price.toFixed(2)}`);
    assert.equal(app.currency, 'INR');
   });
 });
origin: Flood-UI/flood

componentDidMount() {
  if (!this.props.isAdmin) return;

  AuthActions.fetchUsers().then(() => {
   this.setState({hasFetchedUserList: true});
  });
 }
origin: facundoolano/google-play-scraper

function permissions (opts) {
 return new Promise(function (resolve, reject) {
  if (!opts && !opts.appId) {
   throw Error('appId missing');
  }

  opts.lang = opts.lang || 'en';

  processPermissions(opts)
   .then(resolve)
   .catch(reject);
 });
}
origin: cube-js/cube.js

export function unregister() {
 if ('serviceWorker' in navigator) {
  navigator.serviceWorker.ready.then(registration => {
   registration.unregister();
  });
 }
}
origin: asciidwango/js-primer

describe(URL, function() {
  it("ロードするとApp.jsのログが表示される", function() {
    visitWithConsole(URL).then(({ logSpy }) => {
      const log0 = logSpy.getCall(0).args[0];
      const log1 = logSpy.getCall(1).args[0];
      expect(log0).to.equal("App.js: loaded");
      expect(log1).to.equal("App initialized");
    });
  });
});
origin: cube-js/cube.js

function runQueryTest(q, expectedResult) {
  return compiler.compile().then(() => {
   const query = new PostgresQuery({ joinGraph, cubeEvaluator, compiler }, q);

   console.log(query.buildSqlAndParams());

   return dbRunner.testQuery(query.buildSqlAndParams()).then(res => {
    console.log(JSON.stringify(res));
    res.should.be.deepEqual(
     expectedResult
    );
   });
  });
 }
origin: facundoolano/google-play-scraper

it('should get the developer physical address', () => {
  return gplay.app({ appId: 'com.snapchat.android' })
   .then((app) => {
    assert.equal(app.developerAddress, '63 Market St.\nVenice CA, 90291');
   });
 });
origin: cube-js/cube.js

export function unregister() {
 if ('serviceWorker' in navigator) {
  navigator.serviceWorker.ready.then(registration => {
   registration.unregister();
  });
 }
}
origin: cube-js/cube.js

export function unregister() {
 if ('serviceWorker' in navigator) {
  navigator.serviceWorker.ready.then(registration => {
   registration.unregister();
  });
 }
}
origin: cube-js/cube.js

export function unregister() {
 if ('serviceWorker' in navigator) {
  navigator.serviceWorker.ready.then(registration => {
   registration.unregister();
  });
 }
}
builtins(MDN)Promisethen

JSDoc

Attaches callbacks for the resolution and/or rejection of the Promise.

Most used builtins functions

  • Console.log
  • Console.error
  • Promise.then
    Attaches callbacks for the resolution and/or rejection of the Promise.
  • Promise.catch
    Attaches a callback for only the rejection of the Promise.
  • Array.push
    Appends new elements to an array, and returns the new length of the array.
  • Array.length,
  • Array.map,
  • String.indexOf,
  • fetch,
  • Window.location,
  • Window.addEventListener,
  • ObjectConstructor.keys,
  • Array.forEach,
  • Location.reload,
  • Response.status,
  • Navigator.serviceWorker,
  • ServiceWorkerContainer.register,
  • ServiceWorkerRegistration.installing,
  • ServiceWorkerContainer.controller

Popular in JavaScript

  • debug
    small debugging utility
  • mongodb
    The official MongoDB driver for Node.js
  • through2
    A tiny wrapper around Node.js streams.Transform (Streams2/3) to avoid explicit subclassing noise
  • ms
    Tiny millisecond conversion utility
  • cheerio
    Tiny, fast, and elegant implementation of core jQuery designed specifically for the server
  • minimist
    parse argument options
  • http
  • bluebird
    Full featured Promises/A+ implementation with exceptionally good performance
  • q
    A library for promises (CommonJS/Promises/A,B,D)
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now