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

Bugfix/fixing try catch in imagem perfil usuario service get imagem perfil usuario by id usuario #26

Conversation

alexfariakof
Copy link
Owner

A API Rest retorna um BadRequest ao ocorrer erro que anteriormente retornava um OkResult, forçando assim colocar um retorno null do catch Exception no método getImagemPerfilUsuarioByIdUsuario.

const getImagemPerfilUsuarioByIdUsuario = async (): Promise<ImagemPerfilUsuarioVM | any> => {
try {
const accessToken = localStorage.getItem('@dpApiAccess')?.replaceAll('"', '');
const idUsuario = Number(localStorage.getItem('idUsuario'));

const url = `/ImagemPerfilUsuario/GetByIdUsuario/${idUsuario}`;

const headers = {
  Authorization: `Bearer ${accessToken}`,
  'Content-Type': 'multipart/form-data',
};

const { data } = await Api.get(url, { headers });

if (data.message === true) {
  return data.imagemPerfilUsuario;
} else {
  return null;
}

}
catch {
return null;
}
};

@alexfariakof alexfariakof merged commit de4f345 into develop Oct 21, 2023
5 checks passed
@sonarcloud
Copy link

sonarcloud bot commented Oct 21, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@alexfariakof alexfariakof deleted the bugfix/fixing-try-catch-in-ImagemPerfilUsuarioService-getImagemPerfilUsuarioByIdUsuario branch October 21, 2023 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant