Removed repeated code and added reusability for scoring tasks

This commit is contained in:
Leoh 2021-10-23 18:06:04 +05:30
parent 977cacb8f6
commit a8a4e32f7b
2 changed files with 37 additions and 112 deletions

View file

@ -2,7 +2,7 @@
export async function getStats(username: string, credentials: string){
const url = "https://habitica.com/export/userdata.json"
const response = fetch(url, {
const response = await fetch(url, {
method: 'GET',
headers: {
"Content-Type": "application/json",
@ -11,7 +11,7 @@ export async function getStats(username: string, credentials: string){
"x-api-key": credentials,
},
})
return (response)
return (await response)
}
export async function scoreTask(username: string, credentials: string, taskID: string, direction: string) {