{"id":47354,"library":"curl2axios","title":"curl2axios","description":"A lightweight package (v0.0.3) that provides an Axios interceptor to generate cURL commands from Axios HTTP requests. It helps in debugging by converting Axios request configuration to equivalent cURL strings. The library ships TypeScript definitions and requires Axios ^1.6.7 as a peer dependency. Useful for developers wanting to replicate or debug Axios requests via cURL.","status":"active","version":"0.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/4lessandrodev/curl2axios","tags":["javascript","Curl","Dev Request","Axios","Debug","typescript"],"install":[{"cmd":"npm install curl2axios","lang":"bash","label":"npm"},{"cmd":"yarn add curl2axios","lang":"bash","label":"yarn"},{"cmd":"pnpm add curl2axios","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for intercepting Axios requests.","package":"axios","optional":false}],"imports":[{"note":"CurlInterceptor is a named export, not default. Use named import.","wrong":"import CurlInterceptor from 'curl2axios'","symbol":"CurlInterceptor","correct":"import { CurlInterceptor } from 'curl2axios'"},{"note":"The module also offers a default export which is the CurlInterceptor class itself.","wrong":"const { default: curl2axios } = require('curl2axios')","symbol":"default","correct":"import curl2axios from 'curl2axios'"},{"note":"CurlHelper is an additional named utility class.","wrong":"import { CurlHelper } from 'curl2axios' is correct; no wrong pattern.","symbol":"CurlHelper","correct":"import { CurlHelper } from 'curl2axios'"}],"quickstart":{"code":"import axios from 'axios';\nimport { CurlInterceptor } from 'curl2axios';\n\nconst axiosInstance = axios.create();\nconst interceptor = new CurlInterceptor(axiosInstance);\ninterceptor.enable();\n\naxiosInstance.get('https://api.example.com/data', {\n  headers: { 'Authorization': 'Bearer ' + (process.env.API_KEY ?? 'test') }\n}).then(response => {\n  console.log(response.data);\n}).catch(error => {\n  console.error(error);\n});\n\n// After the request, the generated cURL command is printed to console (via interceptor).","lang":"typescript","description":"Shows how to instantiate CurlInterceptor on an Axios instance, enable it, and make a request. The cURL for that request is logged."},"warnings":[{"fix":"Call interceptor.enable() before making any request you want to convert.","message":"Interceptor must be enabled before requests; enabling after a request does not affect past requests.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Pin to exact version or stay updated with changelog.","message":"Package is at version 0.0.3; API may change in future releases.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Override console.log or fork the library to capture output.","message":"The interceptor prints cURL directly to console; there is no built-in way to capture it as a variable without overriding console.log.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'1.6.7':40 'axio':9,16,25,39,53,61 'command':14 'configur':27 'convert':24 'curl':13,30,56,58 'curl2axios':1 'debug':22,52,62 'definit':36 'depend':44 'dev':59 'develop':47 'equival':29 'generat':12 'help':20 'http':17 'interceptor':10 'javascript':57 'librari':33 'lightweight':3 'packag':4 'peer':43 'provid':7 'replic':50 'request':18,26,54,60 'requir':38 'ship':34 'string':31 'typescript':35,63 'use':45 'v0.0.3':5 'via':55 'want':48","created_at":"2026-06-07T16:51:05.806629+00:00","updated_at":"2026-06-07T16:51:05.806629+00:00","problems":[{"fix":"Ensure you import axios correctly: import axios from 'axios' (ESM) or const axios = require('axios') (CJS).","cause":"Incorrect import of 'axios' (e.g., using default import where axios is not the default export).","error":"TypeError: axios.create is not a function"},{"fix":"Use: new CurlInterceptor(axiosInstance) or check that you imported CurlInterceptor correctly: import { CurlInterceptor } from 'curl2axios'.","cause":"Trying to create instance without new keyword or wrong import.","error":"CurlInterceptor is not a constructor"},{"fix":"Ensure interceptor is instantiated: const interceptor = new CurlInterceptor(axiosInstance);","cause":"Interceptor instance not created properly.","error":"Cannot read properties of undefined (reading 'enable')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/4lessandrodev/curl2axios/tree/main/docs","github":"https://github.com/4lessandrodev/curl2axios","docs":null,"changelog":null,"pypi":null,"npm":"curl2axios","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}