Skip to content

Commit bd12fc9

Browse files
committed
feat: Add httpMethod enum
1 parent 567bde9 commit bd12fc9

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/httpMethod.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const httpMethods = {
2+
delete: "DELETE",
3+
get: "GET",
4+
patch: "PATCH",
5+
put: "PUT",
6+
post: "POST"
7+
} as const;
8+
9+
type HttpMethod = typeof httpMethods[keyof typeof httpMethods];
10+
11+
export {httpMethods};
12+
13+
export type {HttpMethod};

src/httpRequest.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import fetch from "isomorphic-fetch";
22

33
import HttpResponseError from "./HttpResponseError";
4+
import {HttpMethod} from "./httpMethod";
45

5-
type RequestJsonParams = Omit<RequestInit, "body"> & {data?: unknown};
6+
type RequestJsonParams = Omit<RequestInit, "body" | "method"> & {
7+
data?: unknown;
8+
method?: HttpMethod;
9+
};
610

711
const responseToJson = (response: Response) => response.json();
812

0 commit comments

Comments
 (0)