在 Web 开发中,我们经常需要将浏览器控制台抓取到的请求逻辑集成到代码里。本工具能将复杂的 cURL 命令 瞬间解析,并生成符合现代 JavaScript 规范的请求代码,支持 Fetch API、Axios 以及 Node.js 原生 方式。
fetch 代码片段,快速实现业务功能。axios 或 request(Node)代码,省去手动解析 Headers 和 Body 的麻烦。mode: 'cors' 或自定义 Header 的请求代码,用于解决调试中的跨域难题。本站工具深度适配了现代 JavaScript 的异步语法与主流网络库:
application/json 请求,自动生成 JSON.stringify() 序列化逻辑。Authorization, Content-Type),自动建议剔除无关的伪头部。async/await 风格的代码,符合现代编码规范,易于阅读和维护。.js 文件或控制台中。原始 cURL:
curl 'https://api.ebtool.com/data' -X POST -H 'Authorization: Bearer abc' -d '{"id": 1}'
生成的 JavaScript 代码 (以 Fetch 为例):
async function postData() {
const response = await fetch('https://api.ebtool.com/data', {
method: 'POST',
headers: {
'Authorization': 'Bearer abc',
'Content-Type': 'application/json'
},
body: JSON.stringify({ 'id': 1 })
});
const result = await response.json();
return result;
}