File tree Expand file tree Collapse file tree 3 files changed +9
-5
lines changed
Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change 88 },
99 "dependencies" : {
1010 "axios" : " ^0.18.0" ,
11- "axios-api-versioning" : " ~1.1 .0"
11+ "axios-api-versioning" : " ~2.0 .0"
1212 },
1313 "devDependencies" : {
1414 "chalk" : " ^2.4.2" ,
Original file line number Diff line number Diff line change 88 "@types/react" : " 16.8.4" ,
99 "@types/react-dom" : " 16.8.2" ,
1010 "axios" : " ^0.18.0" ,
11- "axios-api-versioning" : " ~1.1 .0" ,
11+ "axios-api-versioning" : " ~2.0 .0" ,
1212 "json-server" : " ^0.14.2" ,
1313 "react" : " ^16.8.3" ,
1414 "react-dom" : " ^16.8.3" ,
Original file line number Diff line number Diff line change 11import axios from 'axios' ;
2- import { withVersioning , VersioningStrategy } from 'axios-api-versioning'
2+ import { withVersioning , VersioningStrategy , IWithVersioningConfig } from 'axios-api-versioning'
33
44const axiosInstance = axios . create ( {
55 baseURL : 'http://localhost:4000'
66} ) ;
77
8- const client = withVersioning ( axiosInstance ) ;
8+ const config : IWithVersioningConfig = {
9+ apiVersion : '1' ,
10+ versioningStrategy : VersioningStrategy . MediaType ,
11+ }
12+
13+ const client = withVersioning ( axiosInstance , config ) ;
914
1015/**
1116 * here we manually set the apiVersion & versioningStrategy on every request
@@ -14,7 +19,6 @@ const client = withVersioning(axiosInstance);
1419 * If you have an app where you don't need to mix api versions,
1520 * then set your active version inside the withVersioning()
1621 */
17-
1822export function getBooksByQueryString ( apiVersion : string ) {
1923 return client . get ( 'books' , {
2024 apiVersion,
You can’t perform that action at this time.
0 commit comments