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 🙏

© 2026 – Pkg Stats / Ryan Hefner

dream-axios

v1.0.0

Published

axios,http,kackaging

Readme

Dream-http

  • 说明

    dream-http是基于axios进行二次封装,简单化网络请求
  • 快速上手

    import Vue from 'vue'
    import App from './App.vue'
    import router from './router'
    //1.导入dream-http包
    import DreamHttp from 'dream-axios'
      
      
    Vue.config.productionTip = false
      
    new Vue({
      router,
      render: h => h(App)
    }).$mount('#app')
      
  • new DreamHttp类

    参数

    | 参数名称 | 类型 | 说明 | | ----------- | ------ | -------------------- | | environment | Object | 配置不同环境下根地址 | | overtime | Number | 配置默认请求超时 |

    environment参数列表

    | 参数名称 | 类型 | 说明 | | ----------- | ------ | ------------------ | | environment | String | 开发环境的默认路径 | | production | String | 生产环境的默认路径 | | test | String | 测试环境的默认路径 |

代码例子:

let dreamHttp = new DreamHttp({
    environment:{           //配置不同环境下根地址
     environment:'http://localhost:8999/api/', //开发环境
     production:'http://localhost:8999/api/',  //生产环境
     test:'http://localhost:8999/api/'         //测试
   },
   overtime:1000     //设置请求默认请求超时
})
  • dreamHttp实例对象方法

| 方法名称 | 参数 | 说明 | | ---------- | ------------ | ------------------------------------------------------------ | | requset | function2 | 配置请求拦截方法,参数是两个回调函数,1.默认是请求拦截成功的回调data,2.默认是请求拦截失败的回调err | | response | function2 | 配置响应拦截方法,参数是两个回调函数,1.默认是响应拦截成功的回调data,2.默认是响应拦截失败的回调err | | get | url , params | 设置get请求 | | post | url , params | 设置post请求 | | setApiPath | Object | 设置api接口 | | setToken | Object | 设置令牌 |

代码例子:

let dreamHttp = new DreamHttp({
    environment:{           //配置不同环境下根地址
     environment:'http://localhost:8999/api/', //开发环境
     production:'http://localhost:8999/api/',  //生产环境
     test:'http://localhost:8999/api/'         //测试
   },
   overtime:1000     //设置请求默认请求超时
})


//requset()配置网络请求拦截
dreamHttp.requset(
function(data){  //data为请求拦截成功的回调参数
    
},
function(err){  //err为请求拦截成功的回调参数
    
})

//response()配置响应拦截
dreamHttp.response(
function(data){  //data为响应拦截成功的回调参数
    
},
function(err){  //err为响应拦截成功的回调参数
    
})

//get()网络请求
let id = 10001
dreamHttp.get('/login?id='+id).then(res=>{
    console.log(res)
})
//或者
dreamHttp.get('/login',{id:id}).then(res=>{
    console.log(res)
})

//post()网络请求
dreamHttp.post('/login',{id:id}).then(res=>{
    console.log(res)
})

//设置请求头令牌,参数是一个对象,对象里面需要tokenName,tokenPrice参数
dreamHttp.setToken({
    tokenName:'token',
    tokenPrice:'shadasgysdfgasfdgsfdgfasgdf'
})

//setApiPath()配置每一个接口路径,然后在get,post请求可以直接调用接口api
dreamHttp.setApiPath({
    login:'/login',
    register:'/register'
})

let api = dreamHttp.api

//打印出来api是
//{
//    login:'/login',
//    register:'/register'
//}

dreamHttp.get(api.login,{id:id}).then(res=>{
    console.log(res)
})

报错反应邮箱:[email protected]