美文网首页
react native 网络请求

react native 网络请求

作者: 牵着蜗牛散步Zz | 来源:发表于2018-06-21 18:51 被阅读0次

    1、fetch PUT、POST、GET请求方法:

    requestToTest() {
            return fetch(BASE_NEWUC_URL + 'checkSign/JCBSP000080-01', {
                method: 'GET',
            }) 
            .then((response) => response.json())
            .then((data) => {
                console.log(data);
                return data;
            }).catch((err) => {
                console.log(err);
            });
        }
    
    requestToLogin(account, password) {
    
            return fetch(BASE_NEWUC_URL + 'login', {
                method: 'PUT',
                headers: {
                    'Accept': 'application/json',
                    "Content-Type": "application/x-www-form-urlencoded"
                },
                body: `account=${account}&password=${password}&source=AJ`
            })
            .then((response) => response.json())
            .then((data) => {
                console.log(data);
                return data;
            }).catch((err) => {
                console.log(err);
            });
    }
    
    requestToGetApplyId() {
            return fetch('http://splab.haocheedai.com:8800/fmbg/fm-bg/getApplyId', {
                method: 'POST',
                headers: {
                    'Authorization': 'bc499bf86f800af78fcf28f075eb76ff',
                    'Accept': 'application/json',
                    'Content-Type': 'application/json',
                },
                body: JSON.stringify({
                    'name': '魏昌洲',
                    'telephone': '17621711933',
                    'certNo': '420583199306053410'
                })
            }) 
            .then((response) => response.json())
            .then((data) => {
                console.log(data);
                return data;
            }).catch((err) => {
                console.log(err);
            });
        }
    

    相关文章

      网友评论

          本文标题:react native 网络请求

          本文链接:https://www.haomeiwen.com/subject/lxpcyftx.html