0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

axiosでGET,POSTする

Last updated at Posted at 2020-09-15

axios読み込み

    <script src="https://cdn.jsdelivr.net/npm/axios@0.20.0/dist/axios.js"></script>

#GET

axios.get('/user?ID=12345')
.then(function (response) {
    // handle success
  console.log(response);
})
.catch(function (error) {
    // handle error
  console.log(error);
})
.finally(function () {
    // always executed
});

#POST

const params = new URLSearchParams();
params.append('firstName', 'Mineo');
params.append('lastName', 'Okuda');
axios.post('post-api.php',params)
.then(function (response) {
    // handle success
  console.log(response);
})
.catch(function (error) {
    // handle error
  console.log(error);
})
.finally(function(){
})

#参考
###使い方
axiosとは
axiosライブラリを使って、柔軟にHTTP通信を行う

###GET,POST
CDN版Vue.js + axios でさくっとAjaxしてみる

###JSDELIVER
JSDELIVERのaxiosページ

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?