1
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 2021-05-23

axiosでGET,POST

For Node.js

const axios = require('axios');

GET

const config = { 'Accept': 'application/json' };
axios.get('https://httpbin.org/get', config)
  .then((response) => {
    console.log(response);
    // Do something with response
  })
  .catch((error) => {
    console.log(error);
    // Do something with error
  })

POST

const data = { user: 'john', pass: 'shiba' };
// if you want to set headers 
const headers = { 'Content-Type': 'application/json' };
axios.post('https://httpbin.org/post', data, { headers: headers })
  .then((response) => {
    console.log(response);
    // Do something with response
  })
  .catch((error) => {
    console.log(error);
    // Do something with error
  })

appendix

https://httpbin.org って便利〜

1
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
1
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?