Skip to content

Commit

Permalink
viacep: inject proxy at browser
Browse files Browse the repository at this point in the history
  • Loading branch information
lucianopf committed Apr 29, 2019
1 parent d07fa7d commit cc4ce89
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/services/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ function injectProxy (Service) {

export const CepAbertoService = isBrowser() ? injectProxy(CepAberto) : CepAberto
export const CorreiosService = isBrowser() ? injectProxy(Correios) : Correios
export const ViaCepService = ViaCep
export const ViaCepService = isBrowser() ? injectProxy(ViaCep) : ViaCep
4 changes: 2 additions & 2 deletions src/services/viacep.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import fetch from 'isomorphic-unfetch'
import ServiceError from '../errors/service.js'

export default function fetchViaCepService (cepWithLeftPad) {
const url = `https://viacep.com.br/ws/${cepWithLeftPad}/json/`
export default function fetchViaCepService (cepWithLeftPad, proxyURL = '') {
const url = `${proxyURL}https://viacep.com.br/ws/${cepWithLeftPad}/json/`
const options = {
method: 'GET',
mode: 'cors',
Expand Down

0 comments on commit cc4ce89

Please sign in to comment.