Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 5x 5x 5x 5x 3x 2x 2x 2x | import axios from 'axios'; async function getAddressByCep(cep) { const urlViaCep = 'https://viacep.com.br'; try { const url = `${urlViaCep}/ws/${cep}/json`; const response = await axios({ method: 'get', headers: { 'Content-Type': 'application/json', }, url, }); if (response && response.data && !response.data.erro) return response.data; return null; } catch (err) { const workplaceErr = err.response && err.response.data && err.response.data; console.log(workplaceErr || err); } } export default { getAddressByCep, }; |