Skip to content

Commit

Permalink
Remove unnecessary noop
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv committed Aug 30, 2018
1 parent 8f84cec commit bd970fd
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/ui/public/kfetch/kfetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,17 @@ export async function kfetch(
// Request hooks start from the newest interceptor and end with the oldest.
function requestInterceptors(config: KFetchOptions): Promise<KFetchOptions> {
return interceptors.reduceRight((acc, interceptor) => {
return acc.then(interceptor.request || noop, interceptor.requestError);
return acc.then(interceptor.request, interceptor.requestError);
}, Promise.resolve(config));
}

// Response hooks start from the oldest interceptor and end with the newest.
function responseInterceptors(responsePromise: Promise<any>) {
return interceptors.reduce((acc, interceptor) => {
return acc.then(interceptor.response || noop, interceptor.responseError);
return acc.then(interceptor.response, interceptor.responseError);
}, responsePromise);
}

const noop = (v: any) => v;

async function getBodyAsJson(res: Response) {
try {
return await res.json();
Expand Down

0 comments on commit bd970fd

Please sign in to comment.