美文网首页
aios的基本使用

aios的基本使用

作者: 1462a2c022bc | 来源:发表于2018-10-06 14:53 被阅读0次

1) 发送get方式的请求

      // 不带参数

        axios.get('url').then((response) => {

            console.log(response)

        }).catch((err) => {

            console.log(err)

        })

        // 带参数 方式1

        axios.get('url?username=admin&password=123').then((response) => {

            console.log(response)

        }).catch((err) => {

            console.log(err)

        })

        // 带参数 方式2

        axios.get('url', {

            params: {

                username: "admin",

                password: 123

            }

        }).then((response) => {

            console.log(response)

        }).catch((err) => {

            console.log(err)

        })

    2) 发送post方式的请求

    axios.post('url', {

        username: "admin",

        password: 123

    })

    .then((response) => {

        console.log(response)

    })

    .catch(err => {

        console.log(err);

    })

相关文章

网友评论

      本文标题:aios的基本使用

      本文链接:https://www.haomeiwen.com/subject/fadhaftx.html