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

vue-resource-case-converter

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-resource-case-converter

Vue resource plugin to convert request json keys to snake_case and response json keys to camelCase

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-63.64%
Maintainers
1
Weekly downloads
 
Created
Source

vue-resource-case-converter

Module attaches interceptors to vue instance which process request and responses to convert keys on JSON objects to camelCase for responses and snake_case for requests.

Your vue instance should have vue-resource plugin installed and connected.

Why?

Very often popular backends use snake case as their default code style, while camel case is usually used in javascript.

This module can be used to keep consistent code style on both backend and your vue frontend.

Installation

$ npm i vue-resource-case-converter

Then in your code:

const Vue = require('vue');
const VueResource = require('vue-resource');
const VueResourceCaseConverter = require('vue-resource-case-converter');

Vue.use(VueResource);
Vue.use(VueResourceCaseConverter);

Configuration

In order to restrict certain urls from converting, you can do it by providing responseUrlFilter or requestUrlFilter function to configuration object. These functions receive url and should return true for url to be processed by interceptor.

Vue.use(VueResourceCaseConverter, {
  responseUrlFilter(url) {
    // Your custom logic
    // For example:
    // return url.indexOf('api') >= 0;
  },

  requestUrlFilter(url) {
    // Your custom logic
  },
});

Notes

This plugin was inspired by this angular.js version.

Keywords

FAQs

Package last updated on 17 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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