首页 > 其他 > 详细

使用promise方式来获取网络数据

时间:2018-05-17 12:40:44      阅读:158      评论:0      收藏:0      [点我收藏+]

获取网络数据

    let data = [];

    new Promise(function(resolve,reject){
        axios.post(‘api.php‘).then(function(response){
            resolve(response);
        },function(error){
            reject({data:[]});
        });
    }).then(function(resolve){
        console.log(‘数据来了‘);
        console.log(resolve.data);
        data = resolve.data;
    },function(reject){
        console.log(reject);
        data = reject.data;
    });

  

使用promise方式来获取网络数据

原文:https://www.cnblogs.com/wntd/p/9050251.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!