zhereh-frontend

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit e5422d7b6fde54aec993ae7a2ac328a79f5eb1bc
parent 28195804cc71c4cc79e6bd0ed989848e3a3bb997
Author: William Muli <willi.wambu@gmail.com>
Date:   Tue,  8 Aug 2023 11:18:53 +0300

Update wala interface for file uploads and response parsing

Diffstat:
Msrc/lib/wala.ts | 20++++----------------
1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/src/lib/wala.ts b/src/lib/wala.ts @@ -35,7 +35,7 @@ export class Wala { } } - async put(body: string | FormData, contentType: string): Promise<string> { + async put(body: string | File, contentType: string): Promise<string> { const options: RequestInit = { method: 'PUT', body, @@ -68,22 +68,10 @@ export class Wala { if (contentType.includes('application/json')) { return await response.json() - } else if (contentType.includes('text/plain')) { + } else if (contentType.includes('text/plain') || contentType.includes('text/html')) { return await response.text() - } else if (contentType.includes('text/html')) { - return await response.text() - } else if (contentType.includes('application/pdf')) { - return await response.blob() - } else if (contentType.includes('application/msword')) { - return await response.blob() - } else if ( - contentType.includes( - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' - ) - ) { - return await response.blob() } else { - throw new Error(`Unsupported content type: ${contentType}`) - } + return await response.blob() + } } }