mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 19:49:16 +00:00
16 lines
528 B
JavaScript
16 lines
528 B
JavaScript
import { checkResponse, fetchWithCustomTimeout } from './fetchUtil';
|
|
var base64 = require('base-64');
|
|
|
|
export async function addAccount(username, password, token) {
|
|
let access = "";
|
|
if (token) {
|
|
access = `?token=${token}`
|
|
}
|
|
let headers = new Headers()
|
|
headers.append('Credentials', 'Basic ' + base64.encode(username + ":" + password));
|
|
let profile = await fetchWithCustomTimeout(`/account/profile${access}`, { method: 'POST', headers: headers }, 60000)
|
|
checkResponse(profile);
|
|
return await profile.json()
|
|
}
|
|
|