This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
CrunchyDL/components/Crunchyroll/Account.ts

33 lines
879 B
TypeScript
Raw Normal View History

2024-04-16 20:20:30 +02:00
import type { CrunchyLogin } from './Types'
export async function crunchyLogin(geo: string) {
2024-05-08 03:18:15 +02:00
const { data, error } = await useFetch<CrunchyLogin>('http://localhost:9941/api/crunchyroll/login', {
method: 'POST',
query: {
geo: geo
}
2024-05-01 01:45:45 +02:00
})
2024-04-16 20:20:30 +02:00
2024-05-01 01:45:45 +02:00
return { data, error }
2024-04-16 20:20:30 +02:00
}
export async function checkAccount(service: string) {
2024-05-08 03:18:15 +02:00
const { data, error } = await useFetch<CrunchyLogin>(`http://localhost:9941/api/service/check/${service}`, {
2024-05-01 01:45:45 +02:00
method: 'GET'
})
2024-04-16 20:20:30 +02:00
2024-05-01 01:45:45 +02:00
return { data, error }
2024-04-16 20:20:30 +02:00
}
export async function loginAccount(user: string, password: string, service: string) {
2024-05-08 03:18:15 +02:00
const { data, error } = await useFetch<CrunchyLogin>(`http://localhost:9941/api/service/login/${service}`, {
2024-05-01 01:45:45 +02:00
method: 'POST',
body: {
user: user,
password: password
}
})
2024-04-16 20:20:30 +02:00
2024-05-01 01:45:45 +02:00
return { data, error }
2024-04-16 20:20:30 +02:00
}