1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Basic toot in timeline working

This commit is contained in:
Zhiyuan Zheng
2020-10-26 00:27:53 +01:00
parent 996cf0c1e7
commit eefa7e01bd
21 changed files with 483 additions and 284 deletions

View File

@ -13,21 +13,19 @@ export async function client (url, query, { body, ...customConfig } = {}) {
}
}
const queryString = query
? `?${Object.keys(query)
.map(key => `${key}=${query[key]}`)
.join('&')}`
: ''
if (body) {
config.body = JSON.stringify(body)
}
let data
try {
const response = await fetch(
`https://${url}${
Object.keys(query).length
? `?${Object.keys(query)
.map(key => `${key}=${query[key]}`)
.join('&')}`
: ''
}`,
config
)
const response = await fetch(`https://${url}${queryString}`, config)
data = await response.json()
if (response.ok) {
return data