ajax2apipost

1.0.5 • Public • Published

A-Design Logo

🚀 ajax2apipost

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

Install

$ npm install ajax2apipost

Usage

render

const ajaxPara2Apipost = require('ajax2apipost');

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 ajax2apipost

Weekly Downloads

4

Version

1.0.5

License

MIT

Unpacked Size

7.28 kB

Total Files

4

Last publish

Collaborators

  • apipost-lab001