Skip to content

Commit 31bbcac

Browse files
Pineirinkpsherva
authored andcommitted
Axios: Centralize imports
* closes: #168
1 parent 53ed4aa commit 31bbcac

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

src/lib/api/connector.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// This file is part of React-Invenio-Forms
2+
// Copyright (C) 2022 CERN.
3+
//
4+
// React-Invenio-Forms is free software; you can redistribute it and/or modify it
5+
// under the terms of the MIT License; see LICENSE file for more details.
6+
7+
// This file is part of InvenioRDM
8+
// Copyright (C) 2022 CERN.
9+
//
10+
// Invenio RDM is free software; you can redistribute it and/or modify it
11+
// under the terms of the MIT License; see LICENSE file for more details.
12+
13+
import axios from "axios";
14+
15+
const baseAxiosConfiguration = {
16+
withCredentials: true,
17+
xsrfCookieName: "csrftoken",
18+
xsrfHeaderName: "X-CSRFToken",
19+
headers: {
20+
"Accept": "application/json",
21+
"Content-Type": "application/json",
22+
},
23+
};
24+
25+
export const http = axios.create(baseAxiosConfiguration);

src/lib/api/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This file is part of React-Invenio-Forms
2+
// Copyright (C) 2022 CERN.
3+
//
4+
// React-Invenio-Forms is free software; you can redistribute it and/or modify it
5+
// under the terms of the MIT License; see LICENSE file for more details.
6+
7+
export { http } from "./config";

src/lib/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77

88
export * from "./elements";
99
export * from "./forms";
10+
export * from "./api";

0 commit comments

Comments
 (0)