MCPcopy Create free account
hub / github.com/BrasilAPI/BrasilAPI / getNcmByCode

Function getNcmByCode

pages/api/ncm/v1/[code].js:5–21  ·  view source on GitHub ↗
(request, response)

Source from the content-addressed store, hash-verified

3import { getNcmData } from '@/services/sefaz';
4
5async function getNcmByCode(request, response) {
6 const { code } = request.query;
7 const ncmCode = code.replace(/\D/g, '');
8 const allNcmData = await getNcmData();
9 const ncmData = allNcmData.find(
10 ({ codigo }) => codigo.replace(/\D/g, '') === ncmCode
11 );
12
13 if (!ncmData) {
14 throw new NotFoundError({
15 message: 'Código NCM não encontrado',
16 type: 'NCM_CODE_NOT_FOUND',
17 });
18 }
19
20 return response.status(200).json(ncmData);
21}
22
23export default app().get(getNcmByCode);

Callers

nothing calls this directly

Calls 1

getNcmDataFunction · 0.90

Tested by

no test coverage detected