rexios
Utils normalize url params and data for axios rest api request
Why?
Returns normalized parameters and url according to the rest-api convention and saving a single request contract for axios
Install
$ npm install vue-rexios
Note: This project is compatible with node v10+
Usage
GET
const axios = ;const rexios = ; const method = 'get';const baseURL = 'v2/api/user/';const params = id: 123 article: 1; const args = ; // args => ['v2/api/user/123/?article=1'] axiosmethod...args;
POST
const axios = ;const rexios = ; const method = 'post';const baseURL = 'v2/api/user/';const params = id: 123 article: 1; const args = ; // args => ['v2/api/user/', {id: 123, article: 1}] axiosmethod...args;
PUT
const axios = ;const rexios = ; const method = 'put';const baseURL = 'v2/api/user/';const params = id: 123 article: 1; const args = ; // args => ['v2/api/user/123/', {id: 123, article: 1}] axiosmethod...args;
DELETE
const axios = ;const rexios = ; const method = 'put';const baseURL = 'v2/api/user/';const params = id: 123 article: 1; const args = ; // args => ['v2/api/user/123/'] axiosmethod...args;