1
0
mirror of https://github.com/nolanlawson/pinafore synced 2024-12-15 03:44:02 +01:00
Pinafore-Web-Client-Frontend/routes/_api/user.js
Nolan Lawson 5f4e869eeb
add more fine-grained request timeouts (#387)
* add more fine-grained request timeouts

fixes #381

* tweak timeout
2018-06-13 07:38:36 -07:00

20 lines
811 B
JavaScript

import { get, paramsString, DEFAULT_TIMEOUT } from '../_utils/ajax'
import { auth, basename } from './utils'
export function getVerifyCredentials (instanceName, accessToken) {
let url = `${basename(instanceName)}/api/v1/accounts/verify_credentials`
return get(url, auth(accessToken), {timeout: DEFAULT_TIMEOUT})
}
export function getAccount (instanceName, accessToken, accountId) {
let url = `${basename(instanceName)}/api/v1/accounts/${accountId}`
return get(url, auth(accessToken), {timeout: DEFAULT_TIMEOUT})
}
export async function getRelationship (instanceName, accessToken, accountId) {
let url = `${basename(instanceName)}/api/v1/accounts/relationships`
url += '?' + paramsString({id: accountId})
let res = await get(url, auth(accessToken), {timeout: DEFAULT_TIMEOUT})
return res[0]
}