📜  js 捕获被拒绝的承诺 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:56.532000             🧑  作者: Mango

代码示例1
//makeRequest returns promise using resolve(sucess)/reject(failure)
//use .then() the first function passed in will run on sucess, 
//the second function passed in will run on failure
makeRequest('GET',"https://mywebsite.com").then(
    function(r){
        console.log("success");
    },
    function(r){
        console.log("failure");
    }
);