BrasilAPI / BrasilAPI/cep-promise

async/await React Native

Open
#223 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
3k
Forks
317
PR merge metrics
No merged PRs in 30d

Description

Quando tento usar async/await diretamente, lança o erro:

```ts
Possible Unhandled Promise Rejection (id: 0):
TypeError: (0, _cepPromise.cep) is not a function. (In '(0, _cepPromise.cep)(86055645, {
providers: ['correios']
})', '(0, _cepPromise.cep)' is undefined)
```

Criando um async, funciona. Portanto, acredito que o cep-promise deveria ser rearranjado para funcionar com async/await diretamente.

```ts
async function CEP(CEP: string) {
return new Promise(resolve => {
cep(CEP, {timeout: 5000, providers: ['brasilapi']}).then(response => resolve(response));
});
}

const cepResponse = await CEP(userInfo.postal_code);
console.log('cepResponse ', cepResponse);
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the direct async/await call to the `cep` entry point in a React Native environment, then compare it with the wrapper function shown in the issue. Check how the package exports `cep`; done means direct async/await usage works without the reported TypeError and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.