Created
March 18, 2023 13:37
-
-
Save viruskizz/5cd4bca1d90a6f878c7cc3c5018b488f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const axios = require("axios"); | |
// Setup | |
const xkey = ''; // add your credential | |
const token = ''; // add your credential | |
const baseUrl = 'https://api.fbw.center/index.php/v4'; | |
const teamId = ''; | |
const headers = { | |
'x-api-key': xkey, | |
'Authorization': `Bearer ${token}`, | |
'Content-Type': 'application/json', | |
} | |
const uri = `${baseUrl}/admin/teams/${teamId}/praynums`; | |
// GET request | |
const resGet = await axios.get(uri, { | |
params: { | |
startDate: '2023-03-18', | |
}, | |
headers: headers | |
}); | |
console.log(resGet); | |
// POST request update increament record | |
const body = { | |
"date": "2023-03-18", | |
"temple": 1, // ภายในวัดพระธรรมกาย | |
"bus": 0, | |
"branch": 1, // ศูนย์สาขา | |
"home": 1, // บ้านกัลฯ อื่นๆ | |
}; | |
const resPost = await axios.post(uri, body, {headers}); | |
console.log(resPost); | |
// PUT request replace record | |
const putBody = { | |
"date": "2023-03-18", | |
"temple": 0, // ภายในวัดพระธรรมกาย | |
"bus": 0, | |
"branch": 0, // ศูนย์สาขา | |
"home": 0, // บ้านกัลฯ อื่นๆ | |
}; | |
const resPut = await axios.put(uri, putBody, {headers}); | |
console.log(resPut); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment