-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreqmanager.js
More file actions
23 lines (21 loc) · 799 Bytes
/
reqmanager.js
File metadata and controls
23 lines (21 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const axios = require("axios").default;
//Tu devrais transformer ça en un Singleton, genre une classe avec une méthode statique, ce serait plus propre je pense 🤔
module.exports = async function (urlgive, token, data, option) {
let axiosoption = {
method: option.method.toUpperCase(),
"url": urlgive,
headers: { Authorization: 'Bot ' + token, "Content-Type": 'application/json' },
credentials: 'include'
};
if(option.header) {
axiosoption.headers["Content-Type"] = option.header;
};
if (option.method != "get" && option.method != "delete" && !option.callback) {
axiosoption.data = data;
// console.log(axiosoption)
return axios(axiosoption);
}
else {
return await axios(axiosoption);
};
};