JSON POST 请求
输入
curl -X POST "https://api.example.com/orders" -H "Content-Type: application/json" -d '{"sku":"A100","qty":2}'输出
method: "POST", body: "{\"sku\":\"A100\",\"qty\":2}"AppHelp
将 cURL 命令转换为包含 URL、方法、请求头和请求体的 fetch 代码。转换在本地完成,不会发出请求。
const response = await fetch("https://api.example.com/orders", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer TOKEN"
},
body: "{\"sku\":\"A100\",\"qty\":2}",
});
const data = await response.text();将 cURL 命令转换为包含 URL、方法、请求头和请求体的 fetch 代码。转换在本地完成,不会发出请求。
curl -X POST "https://api.example.com/orders" -H "Content-Type: application/json" -d '{"sku":"A100","qty":2}'method: "POST", body: "{\"sku\":\"A100\",\"qty\":2}"