Skip to content

Commit 7a8d0be

Browse files
authored
Merge pull request #189 from ivancorrea/master
Set user-agent error on Browser (merge sem validações dado que é um bugfix)
2 parents 664add8 + a560c54 commit 7a8d0be

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cep-promise",
3-
"version": "4.0.2",
3+
"version": "4.0.3",
44
"description": "Busca por CEP integrado diretamente aos serviços dos Correios e ViaCEP",
55
"main": "dist/cep-promise.min.js",
66
"module": "dist/cep-promise.min.js",

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)