Skip to content

Commit

Permalink
style(module:mock): optimize log style (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk authored Nov 8, 2018
1 parent a255fe0 commit 9cd3671
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/mock/src/mock.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class MockInterceptor implements HttpInterceptor {
// is array
if (Object.keys(mockRequest.queryString).includes(key)) {
if (!Array.isArray(mockRequest.queryString[key])) {
mockRequest.queryString[key] = [ mockRequest.queryString[key] ];
mockRequest.queryString[key] = [mockRequest.queryString[key]];
}
mockRequest.queryString[key].push(value);
} else {
Expand Down Expand Up @@ -123,14 +123,19 @@ export class MockInterceptor implements HttpInterceptor {
body: res,
url: req.url,
});
if (config.log)

if (config.log) {
console.log(
'%c 👽MOCK ',
`%c👽${req.method}->${req.url}->request`,
'background:#000;color:#bada55',
req.url,
response,
req,
);
console.log(
`%c👽${req.method}->${req.url}->response`,
'background:#000;color:#bada55',
response,
);
}
return of(response).pipe(delay(config.delay));
}
}

0 comments on commit 9cd3671

Please sign in to comment.