[Solved] Uniapp Axios appears in wechat applet index.js? [SM]: 33 errortyerror: l is not a function error

The Axios request interface is used in the uniapp, and the mock interface is used to obtain data

Error in running wechat applet: index.js?[sm]:33 errortypeerror: l is not a function

Original writing method (not effective in wechat applet)

import axios from 'axios';
let _url = ' https://mobile-ms.uat.homecreditcfc.cn/mock/xxxxxxx/demo';
             axios.get(_url + '/demoInformation').then((res) => {
                 console.log(res);
                 console.log(res.data);
                 console.log(res.data.data.demoData);
              this.invoicesData = res.data.data.demoData;
             }).catch(function (error) {
                     // Handling error situations
                     console.log(error);
                 });

Solution: use the native request Uni. Request()

// Default Method
uni.request({
    url: 'https://www.example.com/request',
    success: (res) => {
        console.log(res.data);
    },
    fail:(err) => {
        console.error(err)
    }
});

Similar Posts: