0.0.1 • Published 4 years ago

transform-request-to-curl v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

transform-request-to-curl

将请求装换为 curl 语句,transformRequestToCurl(method, url, data, headers)

使用示例

const transformRequestToCurl = require('transform-request-to-curl');

transformRequestToCurl('get', 'http://www.a.com', {username: 'lucy', age: 18}, {cookie: 'token=ShbJEhXhuuuhg98o12_CbBc' });

// 返回:curl 'http://www.a.com?username=lucy&age=18' -H 'cookie: token=ShbJEhXhuuuhg98o12_CbBc'

transformRequestToCurl('post', 'http://www.a.com', {username: 'lucy', age: 18}, {cookie: 'token=ShbJEhXhuuuhg98o12_CbBc' });

// 返回:curl -X 'POST' 'http://www.a.com' -d 'username=lucy&age=18' -H 'cookie: token=ShbJEhXhuuuhg98o12_CbBc'

参数说明

ObjectWriteToFile(data, file);

参数类型是否必传默认值说明
methodStringget请求方法,get/post
urlStringundefined请求路径
dataObject or Arrayundefined请求数据
headersObjectundefined请求头