Skip to content

Commit

Permalink
Merge pull request #63 from dojyorin/dev
Browse files Browse the repository at this point in the history
add base64 response.
  • Loading branch information
dojyorin authored Jul 14, 2023
2 parents 775ec69 + 8128262 commit c34dd6a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {base64Encode} from "./base64.ts";

/**
* Possible input for `URLSearchParams`.
*/
Expand All @@ -15,6 +17,7 @@ export interface FetchInit extends Omit<RequestInit, "integrity" | "window">{
*/
export interface ResponseType{
"text": string;
"base64": string;
"json": unknown;
"form": FormData;
"byte": Uint8Array;
Expand Down Expand Up @@ -53,6 +56,7 @@ export async function fetchExtend<T extends keyof ResponseType>(path:string, typ

switch(type){
case "text": return <ResponseType[T]>await response.text();
case "base64": return <ResponseType[T]>base64Encode(new Uint8Array(await response.arrayBuffer()));
case "json": return <ResponseType[T]>await response.json();
case "form": return <ResponseType[T]>await response.formData();
case "byte": return <ResponseType[T]>new Uint8Array(await response.arrayBuffer());
Expand Down

0 comments on commit c34dd6a

Please sign in to comment.