Skip to content

Commit

Permalink
Remove axios dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
jakejrichards committed Oct 3, 2018
1 parent fa27bd0 commit cab8e29
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 43 deletions.
11 changes: 5 additions & 6 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import axios from 'axios';

type GameMode =
'1v1' | // 1v1 Arena
'ball' | // Gridiron
Expand Down Expand Up @@ -54,13 +52,14 @@ const COD_API_ENDPOINT = 'https://my.callofduty.com/api/papi-client';

// API Helper
function getDataFromAPI(uri: string) {
return axios.get(uri)
.then(({ data }) => {
const { status, data: error } = data;
return fetch(uri)
.then(response => response.json())
.then(response => {
const { status, data: error } = response;
if (status !== 'success') {
throw new Error(`cod-api request failed: ${error.message}`);
}
return data;
return response;
});
}

Expand Down
37 changes: 1 addition & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
],
"license": "MIT",
"dependencies": {
"axios": "^0.18.0",
"typescript": "^3.0.1"
},
"repository": "github:jakejrichards/cod-api",
Expand Down

0 comments on commit cab8e29

Please sign in to comment.