随便弄个模板好找

wx

    let self = this
    try {
      const token = wx.getStorageSync('token')
      if (token) {
        wx.request({
          method: 'POST',
          url: 'https://www.xiaoming.net.cn/api/v1/article/readarticletype',
          header: {
            'content-type': 'application/x-www-form-urlencoded',
            'Authorization': 'Bearer '+token
          },
          success(res) {
            console.log(res.data)

          }
        })
      }
    } catch (e) {
      // Do something when catch error
    }

axios

    this.axios.get('/api/v1/***', {
      headers: {
        'Authorization': 'Bearer '+localStorage.getItem('token')
      }
    })
      .then((res) => {
        console.log(res);
      })
      .catch((error) => {
        console.log(error);
      });
      let data = new FormData();
      data.append('enterprise', this.writeFeel.company);

      this.axios({
        method: 'post',
        url: '/api/v1/***',
        headers: {
          'Content-type': 'multipart/form-data',
          'Authorization': 'Bearer '+localStorage.getItem('token')
        },
        data: data
      })
        .then((res) => {
          console.log(res);
        })
        .catch((error) => {
          console.log(error);
        });
posted @ 2019-03-03 00:20  五个唔  阅读(158)  评论(0编辑  收藏  举报