1.1.12 • Published 4 years ago

http-listeners v1.1.12

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

http请求监控http-listeners

  • 可全局监控XMLHttpRequest(Ajax)和fetch的请求的请求参数,响应体,响应时间。用于日后的日志分析

使用

  • 安装
npm i --save http-listeners

或者

cnpm i --save http-listeners
  • 全局调用即可
import ajaxListener from 'http-listeners'

// 初始化
ajaxListener.init({
  sysApiPrefix: 'api', // 要监控的API前缀,为了去除掉不必要的请求
  filterApiPrefix: '/api/fly' // 要去除的api前缀,主要是为了防止上报接口
})
// 监听
ajaxListener.intercept = (data) => {
  console.log(data)
}

API

ajaxListener.init

  • 方法 监听初始化
  • Params obj
字段说明必须
sysApiPrefix要监控的API前缀N
filterApiPrefix要去除的api前缀N
  • 示例
ajaxListener.init({
  sysApiPrefix: 'api', // 要监控的API前缀,为了去除掉不必要的请求
  filterApiPrefix: '/api/fly' // 要去除的api前缀,主要是为了防止上报接口
})

ajaxListener.intercept

  • 方法的定义(回调函数) 监听
  • data obj
  • data说明
字段说明示例值
querys路径参数{name:'zhao', age: 11}
urlurlhttps://github.com/zhaodeezhu/http-listeners
path包含query参数的urlhttps://github.com/zhaodeezhu/http-listeners?name=zhao
os操作系统win7
browser浏览器版本Chrome 78.0.3904.108
responseText响应体
resTime接口响应时间ms235
  • 示例
// 监听
ajaxListener.intercept = (data) => {
  console.log(data)
}
1.1.12

4 years ago

1.1.11

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago