• react native 请求注意事项


    请求地址一定得为域名形式,不能是ip####

    错误请求:axios.get('127.0.0.1:3000/test').then(res=>{}).catch(err=>{})//会进入catch里面
    正确请求:axios.get('http://asd.tunnel.qydev.com/test').then(res=>{}).catch(err=>{})//请求成功
    

    axios.get请求####

    axios.get('http://asd.tunnel.qydev.com/test',{
          params:{
            username: 'xxx',
            pass: 'xxx'
          }
        })
          .then(res => {
            console.log('res:', res)
          })
          .catch(err => {
            console.log('err:', err)
          })
    

    axios.post请求####

    axios.post('/user', {
        firstName: 'Fred',
        lastName: 'Flintstone'
      })
      .then(function (response) {
        console.log(response);
      })
      .catch(function (error) {
        console.log(error);
      });
    

    async await写法####

    async getData(){
          // let data = await axios.get('http://asd.tunnel.qydev.com/test')
          let data = await axios.post('http://asd.tunnel.qydev.com/login',{name:'123',pass:'123'})
          console.log('data:', data)
    }
    
  • 相关阅读:
    svn客户端使用
    svn服务端搭建
    数组和链表
    旅行商算法
    大O表示法
    交互页面的一些设计规则
    正则表达式大全
    初识算法—二分法初探
    log4j配置
    品优购商城项目(二)mybatis分页插件
  • 原文地址:https://www.cnblogs.com/yzyh/p/10120254.html
Copyright © 2020-2023  润新知