Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set user-agent error on Browser #189

Merged
merged 2 commits into from
Dec 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cep-promise",
"version": "4.0.2",
"version": "4.0.3",
"description": "Busca por CEP integrado diretamente aos serviços dos Correios e ViaCEP",
"main": "dist/cep-promise.min.js",
"module": "dist/cep-promise.min.js",
Expand Down
7 changes: 5 additions & 2 deletions src/services/viacep.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ export default function fetchViaCepService (cepWithLeftPad, proxyURL = '') {
method: 'GET',
mode: 'cors',
headers: {
'content-type': 'application/json;charset=utf-8',
'user-agent': ''
'content-type': 'application/json;charset=utf-8'
}
}

if (typeof window == 'undefined') {
options.headers['user-agent'] = 'cep-promise'
}

lucianopf marked this conversation as resolved.
Show resolved Hide resolved
return fetch(url, options)
.then(analyzeAndParseResponse)
.then(checkForViaCepError)
Expand Down