Native applet request environment configuration

1. The first step is to get the base address of https, log in to the official website of WeChat Mini Program Development, and then enter Development-Development Management-Development Settings,

Add the address of https in the server domain name

2. Send a request to obtain data

1---Write a method to trigger a request, and then use the built-in API of the applet---wx.request   document to connect

/* 这是一个点击事件 */
  lalla(){
    wx.request({
      /* 请求的地址 */
      url: 'https://applet-base-api-t.itheima.net/api/get',
      /* 请求的类型 */
      method:'GET',
      /* 请求的参数必须写在data中 */
      data:{
        name:'gjk',
        age:18
      },
      /* 这是请求成功后返回的数据 */
      success:(res) =>{
        console.log(res)
      }
    })
  },

Guess you like

Origin blog.csdn.net/weixin_57127914/article/details/131035058