m-fe-plugin-fetch
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

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' 请求方法
url string - 请求地址
[x:string] string - body或者header的参数,如果是header-开头,则会被处理成headers中的字段,body-或者直接变量名,则直接处理成body中的字段

变量使用说明

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

Package Sidebar

Install

npm i m-fe-plugin-fetch

Weekly Downloads

2

Version

0.1.0

License

BSD-3-Clause

Unpacked Size

12.2 kB

Total Files

14

Last publish

Collaborators

  • chj736881645