Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-request

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-request - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

README.md

63

index.js

@@ -1,3 +0,60 @@

module.exports = function () {
console.log('it is for Vue.js')
}
(function () {
const axios = require('axios')
const pathToRegexp = require('path-to-regexp')
const qs = require('qs')
//create path compiler
function compilePath (path, paramsObj) {
return pathToRegexp.compile(path)(paramsObj)
}
//define vue-request
const VueRequest = {}
/**
* Vue.use(VueRequest, {
* headers: {
* 'Content-Type': 'application/x-www-form-urlencoded'
* }
* })
*
* this.$http.get(someUrl, data, config) same as axios
* @param {[Object]} options [description]
*/
VueRequest.install = function (Vue, options) {
const instance = axios.create(options)
instance.interceptors.request.use(function (config) {
if (config.urlParams) {
config.url = compilePath(config.url, config.urlParams)
}
//x-www-form-urlencoded
if (config.headers['Content-Type'] && config.headers['Content-Type'].indexOf('application/x-www-form-urlencoded') !== -1 && config.data) {
config.data = qs.stringify(config.data, {encode: false})
}
//form data
if (config.headers['Content-Type'] && config.headers['Content-Type'].indexOf('multipart/form-data') !== -1 && config.data) {
const data = config.data
const formData = new FormData()
Object.keys(data).forEach((v,i) => {
formData.append(v, data[v])
})
config.data = formData
}
return config
})
Vue.prototype.$http = instance
}
if (typeof exports == "object") {
module.exports = VueRequest
} else if (typeof define == "function" && define.amd) {
define([], function(){ return VueRequest })
} else if (typeof window !== 'undefined' && window.Vue) {
Vue.use(VueRequest, options)
}
})()
{
"name": "vue-request",
"version": "1.0.0",
"version": "1.0.1",
"description": "a http client for Vue.js based on axios",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/xiadd/vue-request"
},
"scripts": {

@@ -13,3 +17,8 @@ "test": "echo \"Error: no test specified\" && exit 1"

"author": "xiadd",
"license": "ISC"
"license": "ISC",
"devDependencies": {
"axios": "^0.15.3",
"path-to-regexp": "^1.7.0",
"qs": "^6.4.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc