ajax-apipost

1.0.7 • Public • Published

A-Design Logo

🚀 ajax-apipost

Convert common jquery Ajax parameter formats to Apipost standard parameter formats.

Install

$ npm install ajax-apipost

Usage

render

const ajaxPara2Apipost = require("ajax-apipost");

let json = ajaxPara2Apipost({
  url: "https://echo.apipost.cn/get.php",
  data: JSON.stringify({ id: { title: "大三大四的" } }),
  type: "POST",
  headers: {
    "X-Test-Header": "test-value",
    Accept: "application/json; charset=utf-8",
  },
  contentType: "application/json",
});

console.log(json);

/*
{
    "target_id": "ad14d85c-6f22-4ba6-a9c8-3283bd05acdd",
    "url": "https://echo.apipost.cn/get.php",
    "request": {
        "url": "https://echo.apipost.cn/get.php",
        "header": {
            "parameter": [
                {
                    "is_checked": 1,
                    "key": "content-type",
                    "value": "application/json"
                },
                {
                    "is_checked": 1,
                    "key": "X-Test-Header",
                    "value": "test-value"
                },
                {
                    "is_checked": 1,
                    "key": "Accept",
                    "value": "application/json; charset=utf-8"
                }
            ]
        },
        "query": {
            "parameter": [
                
            ]
        },
        "body": {
            "mode": "json",
            "parameter": [
                
            ],
            "raw": "{\"id\":{\"title\":\"大三大四的\"}}"
        },
        "auth": {
            "type": "noauth"
        }
    },
    "method": "POST"
}
*/

Package Sidebar

Install

npm i ajax-apipost

Weekly Downloads

8

Version

1.0.7

License

MIT

Unpacked Size

7.31 kB

Total Files

4

Last publish

Collaborators

  • chengyang12138
  • proud_lion
  • lee-meng
  • wjzhangq
  • apipost-lab001
  • xbw19975
  • trqdz