1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00
This commit is contained in:
Zhiyuan Zheng
2021-01-22 01:34:20 +01:00
parent 31b2f67feb
commit 7c6aba77ba
39 changed files with 449 additions and 295 deletions

View File

@ -35,11 +35,13 @@ const client = async <T = unknown>({
localIndex !== undefined ? localIndex : state.local.activeIndex
let domain = null
let token = null
if (instance === 'remote') {
domain = instanceDomain || state.remote.url
} else {
if (theLocalIndex !== null && state.local.instances[theLocalIndex]) {
domain = state.local.instances[theLocalIndex].url
token = state.local.instances[theLocalIndex].token
} else {
console.error(
ctx.bgRed.white.bold(' API ') + ' ' + 'No instance domain is provided'
@ -69,8 +71,8 @@ const client = async <T = unknown>({
headers: {
'Content-Type': 'application/json',
...headers,
...(instance === 'local' && {
Authorization: `Bearer ${state.local!.instances[theLocalIndex!].token}`
...(token && {
Authorization: `Bearer ${token}`
})
},
...(body && { data: body }),