Skip to content

Commit

Permalink
refactor: main contents mock data 수정
Browse files Browse the repository at this point in the history
mock data response interface가 실제 API 응답과 맞지않은 부분을 수정함

ref #44
  • Loading branch information
ppark2ya committed Feb 10, 2022
1 parent 6c11790 commit 70b8a93
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions mocks/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,23 @@ import { ContentsFactory, ErrorResponseFactory } from './factories';
export const handlers = [
rest.get(`${API_URL}/services/main_contents`, (req, res, ctx) => {
const keyword = req.url.searchParams.get('keyword');
const start = Number(req.url.searchParams.get('start'));
const count = Number(req.url.searchParams.get('count'));

const contents = ContentsFactory.buildList(100);

if (keyword !== 'invalid') {
return res(ctx.status(200), ctx.json(contents.splice(0, start + count)));
const start = Number(req.url.searchParams.get('start'));
const count = Number(req.url.searchParams.get('count'));
const contents = ContentsFactory.buildList(count);

return res(
ctx.status(200),
ctx.json({
msg: 'success!',
data: {
main_contents_list: contents,
is_last: false,
start,
},
}),
);
} else {
const errorResponse = ErrorResponseFactory.build();
return res(ctx.status(422), ctx.json(errorResponse));
Expand Down

0 comments on commit 70b8a93

Please sign in to comment.