Add axios library to frontend with base repository

This commit is contained in:
Dana Lambert 2021-10-07 10:22:07 +13:00
parent b699e50754
commit 9b17536102
4 changed files with 33 additions and 0 deletions

View file

@ -11,6 +11,7 @@
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"axios": "^0.22.0",
"bootstrap": "^5.1.2",
"node-sass": "^6.0.1",
"react": "^17.0.2",
@ -4712,6 +4713,14 @@
"node": ">=4"
}
},
"node_modules/axios": {
"version": "0.22.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.22.0.tgz",
"integrity": "sha512-Z0U3uhqQeg1oNcihswf4ZD57O3NrR1+ZXhxaROaWpDmsDTx7T2HNBV2ulBtie2hwJptu8UvgnJoK+BIqdzh/1w==",
"dependencies": {
"follow-redirects": "^1.14.4"
}
},
"node_modules/axobject-query": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz",
@ -26538,6 +26547,14 @@
"resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.3.3.tgz",
"integrity": "sha512-/lqqLAmuIPi79WYfRpy2i8z+x+vxU3zX2uAm0gs1q52qTuKwolOj1P8XbufpXcsydrpKx2yGn2wzAnxCMV86QA=="
},
"axios": {
"version": "0.22.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.22.0.tgz",
"integrity": "sha512-Z0U3uhqQeg1oNcihswf4ZD57O3NrR1+ZXhxaROaWpDmsDTx7T2HNBV2ulBtie2hwJptu8UvgnJoK+BIqdzh/1w==",
"requires": {
"follow-redirects": "^1.14.4"
}
},
"axobject-query": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz",

View file

@ -6,6 +6,7 @@
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"axios": "^0.22.0",
"bootstrap": "^5.1.2",
"node-sass": "^6.0.1",
"react": "^17.0.2",

1
frontend/src/config.js Normal file
View file

@ -0,0 +1 @@
export const API_URL = "http://localhost:8000";

View file

@ -0,0 +1,14 @@
import axios from "axios"
import { API_URL } from "../config";
// Base URL used by all requests
const baseUrl = API_URL;
// Create the axios object
const repo = axios.create({
baseURL: baseUrl,
});
repo.defaults.headers.post["access-control-allow-origin"] = "*";
export default repo;