vue-axios-cors

This is http client vue.js plugin for cross origin access without preflight. It will automatically convert application/json to simple request (application/x-www-form-urlencoded).
14,521 5
Install
npm install vue-axios-cors
Latest Version:1.0.1
Vue:2
License:MIT
Last Updated:Jan 10, 2025
Links: GitHub  ·  npm
Maintainer: gyarasu

vue-axios-cors

This is http client vue.js plugin for cross origin access without preflight. It will automatically convert application/json to simple request (application/x-www-form-urlencoded).

Details

  • POST and PUT method will be converted.
  • HTTP Header:
    • before: application/json
    • after: application/x-www-form-urlencoded
  • What you have to do on your server:
    • Allow CORS Access
    • Add middleware to convert formdata to json data

Installation

$ yarn add vue-axios-cors

Usage

import Vue from 'vue'
import AxiosPlugin from 'vue-axios-cors';

Vue.use(AxiosPlugin)
<script>
export default {
  methods: {
    login() {
      const options = {
        url: 'https://yourdomain.com/login',
        method: 'POST',
        data: {
          email: 'user@example.com',
          password: 'pasw0rd'
        }
      }
      this.$axios(options)
      .then((res) => {
        console.log('Login suceeded!')
      })
      .catch((err) => {
        console.error('Login failed.');
      })
    }
  }
}
</script>

Related Packages

iot-axios2

kaifangpingtai-vue2

1,597
@epoundor/vue-fetch

The ultimate solution for making API calls in your Vue.js projects

1,592 7
vue-axios

A small wrapper for integrating axios to Vuejs

5,218,200 1,996
vue-axios-plugin

axios plugin for Vuejs project

3,206 58
huume-nuxt-axios

Secure and easy Axios integration with Nuxt.js

2,547 1,184

Version History

Version Released Vue License
1.0.1 ^2.6.10 MIT