Skip to content

Commit

Permalink
fix: Change HTTP methods to uppercase
Browse files Browse the repository at this point in the history
  • Loading branch information
neet committed Dec 22, 2022
1 parent b7ac80c commit 873a8e2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/http/base-http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export abstract class BaseHttp implements Http {

get<T>(url: string, data?: Data, init: Partial<Request> = {}): Promise<T> {
return this.request({
method: 'get',
method: 'GET',
url,
params: data,
...init,
Expand All @@ -47,7 +47,7 @@ export abstract class BaseHttp implements Http {

post<T>(url: string, data?: Data, init: Partial<Request> = {}): Promise<T> {
return this.request({
method: 'post',
method: 'POST',
url,
data,
...init,
Expand All @@ -56,7 +56,7 @@ export abstract class BaseHttp implements Http {

delete<T>(url: string, data?: Data, init: Partial<Request> = {}): Promise<T> {
return this.request({
method: 'delete',
method: 'DELETE',
url,
data,
...init,
Expand All @@ -65,7 +65,7 @@ export abstract class BaseHttp implements Http {

put<T>(url: string, data?: Data, init: Partial<Request> = {}): Promise<T> {
return this.request({
method: 'put',
method: 'PUT',
url,
data,
...init,
Expand All @@ -74,7 +74,7 @@ export abstract class BaseHttp implements Http {

patch<T>(url: string, data?: Data, init: Partial<Request> = {}): Promise<T> {
return this.request({
method: 'patch',
method: 'PATCH',
url,
data,
...init,
Expand Down
2 changes: 1 addition & 1 deletion src/http/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export type Data = unknown;

export type Request = {
readonly url: string;
readonly method: 'get' | 'post' | 'patch' | 'delete' | 'put' | 'options';
readonly method: 'GET' | 'POST' | 'PATCH' | 'DELETE' | 'PUT' | 'OPTIONS';
readonly headers?: Headers;
readonly params?: Data;
readonly data?: Data;
Expand Down
4 changes: 2 additions & 2 deletions src/paginator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Paginator', () => {
});
await paginator.next();
expect(http.request).toBeCalledWith({
method: 'get',
method: 'GET',
url: '/v1/api/timelines',
params: { foo: 'bar' },
});
Expand All @@ -31,7 +31,7 @@ describe('Paginator', () => {
await paginator.next();
await paginator.next();
expect(http.request).toBeCalledWith({
method: 'get',
method: 'GET',
params: {},
url: '/api/v1/timelines/home?max_id=109382006402042919',
});
Expand Down
2 changes: 1 addition & 1 deletion src/paginator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class Paginator<Params, Result>
}

const response: Response<Result> = await this.http.request({
method: 'get',
method: 'GET',
// if no params specified, use link header
url: params ? this.initialUrl : this.nextUrl,
params: params ?? this.nextParams,
Expand Down

0 comments on commit 873a8e2

Please sign in to comment.