File tree Expand file tree Collapse file tree 6 files changed +15
-12
lines changed
Expand file tree Collapse file tree 6 files changed +15
-12
lines changed Original file line number Diff line number Diff line change 11import axios from 'axios' ;
22import qs from 'qs' ;
3- import { API_URL } from 'config' ;
3+ import { API_BASE_URL } from 'config' ;
44
55axios . interceptors . request . use ( ( config ) => {
66 config . headers [ 'Content-Type' ] = 'application/x-www-form-urlencoded' ;
@@ -15,7 +15,7 @@ axios.interceptors.request.use((config) => {
1515
1616function baseRequest ( url , params , method = 'get' ) {
1717 return new Promise ( ( resolve , reject ) => {
18- axios [ method ] ( `${ API_URL } ${ url } ` , params ) . then ( ( response ) => {
18+ axios [ method ] ( `${ API_BASE_URL } ${ url } ` , params ) . then ( ( response ) => {
1919 const json = response . data ;
2020 if ( parseInt ( json . code , 10 ) === 0 ) {
2121 resolve ( json . data ) ;
Original file line number Diff line number Diff line change 11import { get , post } from './request' ;
2+ import * as apis from '@/conf/apis' ;
23
34export default {
4- signIn : ( user , password ) => post ( 'signin.php' , {
5+ signIn : ( user , password ) => post ( apis . SIGN_IN , {
56 user,
67 password
78 } ) ,
8- signOut : ( ) => get ( 'signout.php' ) ,
9+ signOut : ( ) => get ( apis . SIGN_OUT ) ,
910} ;
Original file line number Diff line number Diff line change 11import { get , post } from './request' ;
2+ import * as apis from '@/conf/apis' ;
23
34export default {
4- fetch : ( ) => get ( 'fetch.php' ) ,
5- save : ( todos ) => post ( 'save.php' , {
5+ fetch : ( ) => get ( apis . FETCH_TODO ) ,
6+ save : ( todos ) => post ( apis . SAVE_TODO , {
67 data : JSON . stringify ( todos ) ,
78 action : 'save' ,
89 } ) ,
9- add : ( todo ) => post ( 'save.php' , {
10+ add : ( todo ) => post ( apis . SAVE_TODO , {
1011 data : JSON . stringify ( todo ) ,
1112 action : 'add' ,
1213 } ) ,
13- remove : ( todo ) => post ( 'save.php' , {
14+ remove : ( todo ) => post ( apis . SAVE_TODO , {
1415 data : todo . id ,
1516 action : 'remove' ,
1617 } ) ,
17- modify : ( todo ) => post ( 'save.php' , {
18+ modify : ( todo ) => post ( apis . SAVE_TODO , {
1819 data : JSON . stringify ( todo ) ,
1920 action : 'modify' ,
2021 } ) ,
Original file line number Diff line number Diff line change 11export const FETCH_TODO = 'fetch.php' ;
22export const SAVE_TODO = 'save.php' ;
3+
4+
35export const SIGN_IN = 'signin.php' ;
46export const SIGN_OUT = 'signout.php' ;
Original file line number Diff line number Diff line change 1- // export const API_URL = 'http://172.16.21.236/vue-test-api/';
2- export const API_URL = 'http://127.0.0.1/vue-test-api/' ;
1+ export const API_BASE_URL = 'http://127.0.0.1/vue-test-api/' ;
Original file line number Diff line number Diff line change 1- export const API_URL = 'http://127.0.0.1/vue-test-api/' ;
1+ export const API_BASE_URL = 'http://127.0.0.1/vue-test-api/' ;
You can’t perform that action at this time.
0 commit comments