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

Function getDddsData

services/ddd.js:3–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1import axios from 'axios';
2
3export const getDddsData = async () => {
4 const url =
5 'https://www.anatel.gov.br/dadosabertos/PDA/Codigo_Nacional/PGCN.csv';
6 const LINE_BREAK = '\r\n';
7
8 const { data: reponseData } = await axios({
9 url,
10 method: 'get',
11 responseEncoding: 'binary',
12 });
13
14 const body = reponseData.toString('binary');
15
16 const lines = body.split(LINE_BREAK);
17
18 lines.shift();
19
20 return lines
21 .map((line) => line.split(';'))
22 .map(([ibgeCode, state, city, ddd]) => {
23 return {
24 ibgeCode,
25 state,
26 city,
27 ddd,
28 };
29 });
30};

Callers 1

getCitiesByDddFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected