Skip to content

Instantly share code, notes, and snippets.

@akexorcist
Last active September 13, 2024 19:03
Show Gist options
  • Save akexorcist/ea93ee47d39cf94e77802bc39c46589b to your computer and use it in GitHub Desktop.
Save akexorcist/ea93ee47d39cf94e77802bc39c46589b to your computer and use it in GitHub Desktop.

Revisions

  1. akexorcist revised this gist Feb 11, 2022. No changes.
  2. akexorcist revised this gist Jan 4, 2021. 1 changed file with 8 additions and 10 deletions.
    18 changes: 8 additions & 10 deletions index.js
    Original file line number Diff line number Diff line change
    @@ -1,23 +1,21 @@
    const axios = require('axios')
    const qs = require('querystring')

    ...
    /* ... */

    const requestBody = {
    name: 'Akexorcist',
    age: '28',
    position: 'Android Developer',
    description: 'birthdate=25-12-1989&favourite=coding%20coding%20and%20coding&company=Nextzy%20Technologies&website=http://www.akexorcist.com/',
    awesome: true
    }
    const params = new URLSearchParams()
    params.append('name', 'Akexorcist')
    params.append('age', '28')
    params.append('position', 'Android Developer')
    params.append('description', 'birthdate=25-12-1989&favourite=coding%20coding%20and%20coding&company=Nextzy%20Technologies&website=http://www.akexorcist.com/')
    params.append('awesome', true)

    const config = {
    headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
    }
    }

    axios.post(url, qs.stringify(requestBody), config)
    axios.post(url, params, config)
    .then((result) => {
    // Do somthing
    })
  3. akexorcist revised this gist Aug 14, 2019. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion index.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    const axios = require('axios')
    const qs = require('querystring')

    ...

    @@ -16,7 +17,7 @@ const config = {
    }
    }

    axios.post(url, requestBody, config)
    axios.post(url, qs.stringify(requestBody), config)
    .then((result) => {
    // Do somthing
    })
  4. akexorcist created this gist Jan 3, 2018.
    25 changes: 25 additions & 0 deletions index.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    const axios = require('axios')

    ...

    const requestBody = {
    name: 'Akexorcist',
    age: '28',
    position: 'Android Developer',
    description: 'birthdate=25-12-1989&favourite=coding%20coding%20and%20coding&company=Nextzy%20Technologies&website=http://www.akexorcist.com/',
    awesome: true
    }

    const config = {
    headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
    }
    }

    axios.post(url, requestBody, config)
    .then((result) => {
    // Do somthing
    })
    .catch((err) => {
    // Do somthing
    })