axios如何先请求A接口然后在请求B接口

总结:在第一个then的请求结束后,在添加一个then,表示请求第二个接口,在第二个then里面写第二个接口的请求方式

axios.get("./a.json").then(res=>{ //先请求的a接口
                console.log(res)
            }).then(res=>{
                axios.get("./b.json").then(res=>{ //在请求b接口
                    console.log(res)
                })
            }) //这里可以请求c接口
            .catch(err=>{
                console.log(err);
            })

猜你喜欢

转载自www.cnblogs.com/IwishIcould/p/11780277.html