enhancement(auth): better error message handling

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
Erik Michelson 2023-03-25 18:58:48 +01:00
parent 8e57188ab5
commit ca9836d691
37 changed files with 199 additions and 207 deletions

View file

@ -15,7 +15,7 @@ import type { ImageProxyRequestDto, ImageProxyResponse, MediaUpload } from './ty
* @throws {Error} when the api request wasn't successful.
*/
export const getProxiedUrl = async (imageUrl: string): Promise<ImageProxyResponse> => {
const response = await new PostApiRequestBuilder<ImageProxyResponse, ImageProxyRequestDto>('media/proxy', 'media')
const response = await new PostApiRequestBuilder<ImageProxyResponse, ImageProxyRequestDto>('media/proxy')
.withJsonBody({
url: imageUrl
})
@ -34,7 +34,7 @@ export const getProxiedUrl = async (imageUrl: string): Promise<ImageProxyRespons
export const uploadFile = async (noteIdOrAlias: string, media: Blob): Promise<MediaUpload> => {
const postData = new FormData()
postData.append('file', media)
const response = await new PostApiRequestBuilder<MediaUpload, void>('media', 'media')
const response = await new PostApiRequestBuilder<MediaUpload, void>('media')
.withHeader('HedgeDoc-Note', noteIdOrAlias)
.withBody(postData)
.sendRequest()
@ -48,5 +48,5 @@ export const uploadFile = async (noteIdOrAlias: string, media: Blob): Promise<Me
* @throws {Error} when the api request wasn't successful.
*/
export const deleteUploadedMedia = async (mediaId: string): Promise<void> => {
await new DeleteApiRequestBuilder('media/' + mediaId, 'media').sendRequest()
await new DeleteApiRequestBuilder('media/' + mediaId).sendRequest()
}