Promise Complete with then and catch



    My JavaScript recipes

    The code creates a new Promise object and sets its then method to resolve, which will return the result of the code block, and its catch method to reject, which will throw an error if the code block fails.

    Shortcut: promise.full

    return new Promise((resolve, reject) => {
    }).then((result) => {
    }).catch((err) => {
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.