Added source code files which were left out

This commit is contained in:
Leoh 2021-10-17 18:18:25 +05:30
parent 32f0e6bc98
commit 470157b672
12 changed files with 414 additions and 0 deletions

29
src/view/habiticaAPI.ts Normal file
View file

@ -0,0 +1,29 @@
// import fetch from "node-fetch";
export async function getStats(username: string, credentials: string){
const url = "https://habitica.com/export/userdata.json"
const response = fetch(url, {
method: 'GET',
headers: {
"Content-Type": "application/json",
"x-client": username.concat("-testAPI"),
"x-api-user": username,
"x-api-key": credentials,
},
})
return (response)
}
export async function scoreTask(username: string, credentials: string, taskID: string, direction: string) {
const url = "https://habitica.com/api/v3/tasks/".concat(taskID).concat("/score/").concat(direction)
const response = fetch(url, {
method: 'POST',
headers: {
"Content-Type": "application/json",
"x-client": username.concat("-testAPI"),
"x-api-user": username,
"x-api-key": credentials,
}
})
return(response)
}