其他分享
首页 > 其他分享> > axios

axios

作者:互联网

axios({
        url: 'http://jhzx.cs.jkoo.top/jhzx/openApi/xsScreen/area/issueSolicitation',
        method: 'get',
        params: {
            year:2022,
            orgId: 292
        }
    }).then(() => {
        console.log(111);
    }).catch(() => {
        console.log(222);
    })
// axios请求这样写最后竟然是这样的http://jhzx.cs.jkoo.top/jhzx/openApi/xsScreen/area/issueSolicitation?year=2022&orgId=292
axios({
    url: 'http://jhzx.cs.jkoo.top/jhzx/openApi/xsScreen/area/issueSolicitation?year=2022&orgId=292',
    method: 'get'
}).then(() => {
    console.log(111);
}).catch(() => {
    console.log(222);
})
// 上面写的结果竟然形同这样一样

get请求中只能以query参数的形式传递参数,尽量不要写那种params参数的形式,因为在路由跳转里面这两者是有严格区分的

以下两种方式是一样的

axios.get('http://jhzx.cs.jkoo.top/jhzx/openApi/xsScreen/area/issueSolicitation', {
    year:2022,
    orgId: 292
}).then(() => {
    console.log(111);
}).catch(() => {
    console.log(222);
})
axios({
    url: 'http://jhzx.cs.jkoo.top/jhzx/openApi/xsScreen/area/issueSolicitation',
    method: 'get',
    data: {
        year:2022,
        orgId: 292
    }
}).then(() => {
    console.log(111);
}).catch(() => {
    console.log(222);
})

标签:axios,console,log,jhzx,year,cs
来源: https://www.cnblogs.com/zhumenglong/p/16618644.html