mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 12:39:17 +00:00
16 lines
536 B
JavaScript
16 lines
536 B
JavaScript
import { checkResponse, fetchWithCustomTimeout } from './fetchUtil';
|
|
import base64 from 'react-native-base64'
|
|
|
|
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()
|
|
}
|
|
|