ajax2apipost
v1.0.5
Published
Convert common jquery Ajax parameter formats to Apipost standard parameter formats.
Downloads
10
Readme
🚀 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"
}
*/