cURL 轉換器 — cURL 轉 fetch、Python、Go、PHP
線上將 cURL 指令轉換成 fetch、Node、Python requests、Go、PHP 與 axios 程式碼,並解析方法、參數、標頭、Cookie 與內文。
cURL 指令
請求
POSThttps://api.example.com/v1/orders
查詢參數
2
- expand
- items
- limit
- 20
標頭
2
- Content-Type
- application/json
- Authorization
- Bearer demo_7f3a9c2e41
Cookie
2
- session
- 7d1f0c
- theme
- dark
內文
JSON
{
"customer": "cus_42",
"items": [
{
"sku": "KB-75",
"qty": 1
}
],
"note": "It's a gift"
}選項
壓縮(--compressed)
// Browsers drop forbidden headers (Cookie, Host, Referer…).
// For cookies, use credentials: "include" instead.
// Browser manual redirects return an opaque response; the 3xx status and body are unavailable.
const response = await fetch("https://api.example.com/v1/orders?expand=items&limit=20", {
redirect: "manual",
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer demo_7f3a9c2e41",
"Cookie": "session=7d1f0c; theme=dark"
},
body: JSON.stringify({
"customer": "cus_42",
"items": [
{
"sku": "KB-75",
"qty": 1
}
],
"note": "It's a gift"
})
});
console.log(response.status, await response.text());POST · 25 行 · 警告:0不會送出任何請求
在瀏覽器中執行。指令只會被解析,不會執行,也不會送出任何請求。
相關工具
格式參考資料
工具頁面更新日期: