Skip to content

Commit

Permalink
address
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Selednikov committed Sep 11, 2021
1 parent 93ee577 commit 29df498
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/controller/address.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function updateAddressHandler(req: Request, res: Response) {
export async function getAddressHandler(req: Request, res: Response) {
const userId = get(req, 'user._id');
const addressId = get(req, 'params.addressId');
const address = await findAddress({ _id:addressId });
let address = await findAddress({ _id:addressId });
const Location = get(req, 'path');

res.setHeader('Location', Location);
Expand All @@ -58,12 +58,14 @@ export async function getAddressHandler(req: Request, res: Response) {
return res.sendStatus(404);
}

delete address.userId;

return res.send(address);
}

export async function getAllAddressHandler(req: Request, res: Response) {
const userId = get(req, 'user._id');
const address = await findAllAddress({ userId:userId });
let address = await findAllAddress({ userId:userId });
const Location = get(req, 'path');

res.setHeader('Location', Location);
Expand All @@ -72,6 +74,11 @@ export async function getAllAddressHandler(req: Request, res: Response) {
return res.sendStatus(404);
}

address = address.map((el)=>{
delete el.userId;
return el;
});

return res.send(address);
}

Expand Down

0 comments on commit 29df498

Please sign in to comment.