Registry / devops / fetch-to-curl-ts

fetch-to-curl-ts

JSON →
library1.0.2jsnpmunverified

Convert fetch HTTP request parameters to a cURL command string. Stable v1.0.2 (last release unknown) with TypeScript type definitions included. A fork of leoek/fetch-to-curl with enhanced TypeScript support and improved payload serialization (handles FormData, JSON, text, etc.). Differentiators: type-safe, streams handling, and supports React Native. Dependency on @types/node only for Node.js usage.

npm install fetch-to-curl-ts
INSTALL
IMPORT
SIG · FETCH-TO-CURL-TS
F
fetch-to-curl-ts
devopsjavascriptv1.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fetchToCurl
import { fetchToCurl } from 'fetch-to-curl-ts'
import fetchToCurl from 'fetch-to-curl-ts'
Named export only; no default export.
FetchToCurlOptions
import { FetchToCurlOptions } from 'fetch-to-curl-ts'
Type import for TypeScript users.
fetchToCurl (CommonJS)
const { fetchToCurl } = require('fetch-to-curl-ts')
const fetchToCurl = require('fetch-to-curl-ts')
CommonJS require with destructuring.

Demonstrates converting a GET fetch request with a header into a curl command string.

import { fetchToCurl } from 'fetch-to-curl-ts'; const curlString = await fetchToCurl('https://jsonplaceholder.typicode.com/posts/1', { headers: { accept: 'application/json' } }); console.log(curlString); // Output: curl "https://jsonplaceholder.typicode.com/posts/1" -X GET -H 'accept: application/json'
Debug
Known issues
breakingPackage renamed from fetch-to-curl to fetch-to-curl-ts; existing imports from 'fetch-to-curl' will break.
fix
Update imports to 'fetch-to-curl-ts'.
affects: >=0
gotchafetchToCurl is async; must be awaited or resolved with .then().
fix
Use await or .then() when calling fetchToCurl.
affects: >=1.0.0
gotchaWhen using CommonJS, require('fetch-to-curl-ts') returns an object with a fetchToCurl property — must destructure.
fix
Use const { fetchToCurl } = require('fetch-to-curl-ts').
affects: >=1.0.0
deprecatedIf using @types/node, ensure it is installed as a devDependency for TypeScript users.
fix
Run npm install --save-dev @types/node if using TypeScript in Node environment.
affects: >=0
Errors
Common errors & fixes
TypeError: fetchToCurl is not a function
Default import used instead of named import.
fix
Use `import { fetchToCurl } from 'fetch-to-curl-ts'`.
Cannot find module 'fetch-to-curl-ts'
Package not installed or typo in package name.
fix
Run `npm install fetch-to-curl-ts` and check spelling.
Property 'fetchToCurl' does not exist on type 'typeof import("fetch-to-curl-ts")'
Attempted to use default import in TypeScript.
fix
Use named import: `import { fetchToCurl } from 'fetch-to-curl-ts'`.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies
@types/nodeoptionalneeded for Node.js type definitions
Agent activity
4 hits · last 30 days
node
4
Resources
fetch-to-curl-ts — npm install fetch-to-curl-ts · libregistry