cURL → コード
curl コマンドを貼り付けると、JavaScript fetch、TypeScript、Axios、Python requests、Go、C#、Java、Rust のコードに変換します。クエリパラメーター、ヘッダー、JSON やマルチパートの本文はそのまま維持します。
ブラウザ内だけで動作します。入力した内容はどこにもアップロードされません。
- Method
- POST
- Base URL
- https://api.example.com/v1/orders
Content-Typeapplication/jsonAcceptapplication/json
{"customer_id":"cus_1042","items":[{"sku":"SOFT-01","qty":2}],"currency":"USD"}const options = {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
body: JSON.stringify({
"customer_id": "cus_1042",
"items": [
{
"sku": "SOFT-01",
"qty": 2
}
],
"currency": "USD"
}),
};
const response = await fetch("https://api.example.com/v1/orders", options);
if (!response.ok) {
throw new Error(`Request failed: ${response.status} ${response.statusText}`);
}
const data = await response.json();
console.log(data);Query params, headers and multipart fields stay intact in every language; HEAD requests print the status and headers instead of parsing a body, and a non-ASCII Basic auth pair is encoded as UTF-8. Flags without an equivalent — output files, proxies, retries — are reported on the left instead of being dropped silently.
curl フラグチートシート
クイックリファレンス- -X POST
- メソッドを指定します。curl は -d の本文がある時点で POST を送るため、-X が必要なのは PUT、PATCH、DELETE のときです。
- -H 'Content-Type: application/json'
- ヘッダーごとに -H を繰り返します。Content-Type がないと、サーバーは JSON 本文をフォームデータやテキストとして扱います。
- -d '{"a":1}' / --data-raw
- -d は改行を取り除いて本文をエンコードします。--data-raw はそのまま送るので JSON にはこちらが適しています。
- -u user:pass
- HTTP 基本認証です。user:pass を base64 にして Authorization ヘッダーに入れるため、HTTPS でのみ安全です。
- --json '{"a":1}'
- curl 7.82 以降の省略形です。本文を送って POST に切り替え、Content-Type と Accept: application/json がなければ自動で付けます。
- -F 'file=@photo.png;type=image/png'
- マルチパートのアップロードです。@ はファイルを読み、;type はコンテンツタイプを指定し、name=value は通常のテキスト項目になります。
Node.js の関連文法ガイド
Node.js のガイドをすべて見るNode.js JWT invalid signature: JWKS Rotation and Clock Skew
One message covers three bugs: the wrong key type for RS256 or ES256, a JWKS cache that never refreshes after a kid rotation, and a clock that drifted.
Node.jsERR_REQUIRE_ESM and __dirname Is Not Defined in ESM Projects
require of an ESM-only package has nothing to load, and ESM creates none of the CommonJS wrapper globals. Dynamic import, createRequire, and the path replacements.
Node.jsNode.js fetch ETIMEDOUT and SELF_SIGNED_CERT_IN_CHAIN Debugging
fetch failed hides everything in error.cause. Read the aggregate, trust the private CA the way curl does, route the proxy, and set the connect timeout undici does not.
Node.jsNode.js JavaScript heap out of memory: Snapshots and Real Leaks
Distinguish needs more from leaks before raising the flag: external memory and heap tell different stories, and a heap ceiling at three quarters of the container limit keeps V8 able to report.