Search code examples
javascriptes6-promise

Promise.reject().catch(console.log) got an `Illegal invocation` on my Android 5.1 phone


I've try this on Chrome before and it works well, but on my Android 5.1 phone it got an Illegal invocation


Solution

  • In some browsers, console.log doesn't like being invoked in the global context. You can do one of these:

    Promise.reject().then(function (error) {
       console.log(error);
    });
    

    or

    Promise.reject().then(console.log.bind(console));