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

Create Rick & Morty API #6

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Create Rick & Morty API #6

wants to merge 3 commits into from

Conversation

Dimagaa
Copy link

@Dimagaa Dimagaa commented Oct 19, 2023

No description provided.

Copy link

@andrii-hoienko andrii-hoienko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GJ! Let`s improve your solution

}
);
} catch (IOException | InterruptedException e) {
throw new RuntimeException(e);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to throw custom exception instead of generic one

@EventListener(ApplicationReadyEvent.class)
public void fetchData() {
List<ExternalCharacterDto> characters = new ArrayList<>();
CharacterResponseDataDto response = loadData(characterUrl);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CharacterResponseDataDto response = loadData(characterUrl);
CharacterResponseDataDto characterResponse = loadData(characterUrl);

service.saveAll(characters);
}

private CharacterResponseDataDto loadData(String url) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OPTIONAL: As an alternative way to make http requests it is possible to use feignClient, which from my point of view is a more suitable and agile way of making web clients and request. But actually for current task your solution in ok as well

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.

3 participants