Skip to content

Commit cc4ce89

Browse files
committed
viacep: inject proxy at browser
1 parent d07fa7d commit cc4ce89

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/services/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ function injectProxy (Service) {
1515

1616
export const CepAbertoService = isBrowser() ? injectProxy(CepAberto) : CepAberto
1717
export const CorreiosService = isBrowser() ? injectProxy(Correios) : Correios
18-
export const ViaCepService = ViaCep
18+
export const ViaCepService = isBrowser() ? injectProxy(ViaCep) : ViaCep

src/services/viacep.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import fetch from 'isomorphic-unfetch'
44
import ServiceError from '../errors/service.js'
55

6-
export default function fetchViaCepService (cepWithLeftPad) {
7-
const url = `https://viacep.com.br/ws/${cepWithLeftPad}/json/`
6+
export default function fetchViaCepService (cepWithLeftPad, proxyURL = '') {
7+
const url = `${proxyURL}https://viacep.com.br/ws/${cepWithLeftPad}/json/`
88
const options = {
99
method: 'GET',
1010
mode: 'cors',

0 commit comments

Comments
 (0)