npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fetch-vis

v0.0.1

Published

fetch 封装 支持axios类似相关配置项,支持vue 引入,对不支持fetch 的浏览器做了兼容处理

Downloads

8

Readme

fetch-vis

fetch请求封装 兼容浏览器,当前浏览器不支持fetch 请求类型则会使用xhr,即原ajax 请求

安装

npm install fetch-vis --save
cnpm install fetch-vis --save

引用

import fetch from 'fetch-vis';
const fetch = require("fetch-vis").default;

示例

fetch.get(url[,data,config])
fetch.post(url[,data,config])
fetch.put(url[,data,config])
fetch.delete(url[,data,config])
fetch.head(url[,data,config])
fetch.trace(url[,data,config]) 
fetch.connect(url[,data,config])

以上方法名对应着相对的请求方式

fetch.request({url[,method,data,params,headers]})

<!-- get 请求: /get/user/info?urlparams=1&id=1&params=2  -->
fetch.get('/get/user/info?urlparams=1',{id:1},{params:  {params=2}})
    .then( response=> {
        console.log(response); 
    })
    .catch( error=> {
        console.log(error); 
    });
<!-- post 请求:  -->
fetch.post('/get/user/info?urlparams=1',{id:1},{params:{params=2}})
    .then( response=> {
        console.log(response); 
    })
    .catch( error=> {
        console.log(error); 
    });
<!-- put 请求:  -->
fetch.put('/get/user/info?urlparams=1',{id:1},{params:{params=2}})
    .then( response=> {
        console.log(response); 
    })
    .catch( error=> {
        console.log(error); 
    });
<!-- head 请求:  -->
fetch.head('/get/user/info?urlparams=1',{id:1},{params:{params=2}})
    .then( response=> {
        console.log(response); 
    })
    .catch( error=> {
        console.log(error); 
    });
<!-- trace 请求:  -->
fetch.trace('/get/user/info?urlparams=1',{id:1},{params:{params=2}})
    .then( response=> {
        console.log(response); 
    })
    .catch( error=> {
        console.log(error); 
    });
<!-- delete 请求:  -->
fetch.delete('/get/user/info?urlparams=1',{id:1},{params:{params=2}})
    .then( response=> {
        console.log(response); 
    })
    .catch( error=> {
        console.log(error); 
    });
<!-- connect 请求:  -->
fetch.connect('/get/user/info?urlparams=1',{id:1},{params:{params=2}})
    .then( response=> {
        console.log(response); 
    })
    .catch( error=> {
        console.log(error); 
    });

简介

fetch-vis 支持在vue 环境下直接use 挂载在全局上。

api

{
  method:"", // 默认请求方式 默认是get
  baseURL:"", // 默认 请求域名
  headers:{}, // 发送的自定义请求头
  params:{}, // 是与请求一起发送的 URL 参数 params 现只支持对象形式
  data: {},  // 是与请求一起发送的 body 里面的内容
  /**
    * 注册请求前预处理
    * 还可以通过  fetch.interceptors.request.use(config=>{}) 实现注册
    */
  transformRequest(config=>{
     // 实现内容
  }) , 
  /**
    * 注册请求拦截器
    * 还可以通过  fetch.interceptors.response.use(config=>{},error=>{}) 实现注册
    */
  transformResponse(data=>{
     // 实现内容
  },error=>{
    // 请求错误/失败 实现内容
  }) , 
   
}

版本

  • alpha v0.0.1

    使用ts 编写整体架构。 实现简单请求,拦截器等功能。 兼容不支持fetch请求的浏览器。