Skip to content

Commit e8604d2

Browse files
Ivan Correalucianopf
authored andcommitted
viacep: browser user-agent error
1 parent 664add8 commit e8604d2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/services/viacep.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ export default function fetchViaCepService (cepWithLeftPad, proxyURL = '') {
99
method: 'GET',
1010
mode: 'cors',
1111
headers: {
12-
'content-type': 'application/json;charset=utf-8',
13-
'user-agent': ''
12+
'content-type': 'application/json;charset=utf-8'
1413
}
1514
}
1615

16+
if (typeof window == 'undefined') {
17+
options.headers['user-agent'] = 'cep-promise'
18+
}
19+
1720
return fetch(url, options)
1821
.then(analyzeAndParseResponse)
1922
.then(checkForViaCepError)

0 commit comments

Comments
 (0)