0.1.0 • Published 2 years ago

m-fe-plugin-fetch v0.1.0

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
2 years ago

m-fe-plugin-fetch

命令行请求工具(多用于npm script)

Getting Started

fe fetch 自动安装和运行

使用

  • fe fetch xxx.com --option=xxx 请求某个接口,并携带参数

在npm中使用

"scripts":{
  "update":"fe fetch xxx.com/api --body-a=1 --b=2 --header-Content-Type=application/json"
}

如果命令中用 ; 需要转义 \;

运行结果为:

headers:{ 'Content-Type': 'application/json' }
body:{ a: 1, b: 2 }

option

参数名类型默认值说明
method'GET'|'POST'|'PUT'|'DELETE''GET'请求方法
urlstring-请求地址
[x:string]string-body或者header的参数,如果是header-开头,则会被处理成headers中的字段,body-或者直接变量名,则直接处理成body中的字段

变量使用说明

headersbody 中如果值为 @ 开头的字符串,则,从 package.json 中提取变量,比如: @version 表示 package.json 中的 version 字段, @repository.url 代表 package.json 中的 repository 对象下的 url 字段