Skip to content

Conversation

@Mikadv
Copy link
Contributor

@Mikadv Mikadv commented Aug 6, 2025

To be able to demonstrate better external API usage introduced two new API service:

  • added getPost
  • added getComments
  • removed: getMessage

created a Posts section in the Welcome page with comments where we render these external data.

This is how that section looks like after this change:
Screenshot 2025-10-03 at 13 48 49

@Mikadv Mikadv requested a review from rodet as a code owner August 6, 2025 20:31
@bogy0 bogy0 force-pushed the feat/network-query-examples branch from 2b321ae to 9be2fbc Compare October 3, 2025 11:35
@bogy0 bogy0 changed the title Feat/network query examples feat: add network query example to fetch posts and comments Oct 3, 2025
@bogy0 bogy0 requested a review from lee-chase October 3, 2025 12:28
Copy link
Member

@lee-chase lee-chase left a comment

Choose a reason for hiding this comment

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

Looks good to me, made a couple of small changes to pass linter and remove layer level which was not needed.

try {
const response = await fetch(
// TODO: replace with actual endpoint URL
`https://jsonplaceholder.typicode.com/posts/${id}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should be relying on an external provider here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@rodet To show an API call in the example without using an external provider, what pattern would you prefer? A mocked response, a local stub endpoint, or something else?

try {
// TODO: handle production and development environments
const response = await fetch(
`http://localhost:5173/api/comments?postId=${postId}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any way to remove that hardcoding here?

Copy link
Member

Choose a reason for hiding this comment

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

@rodet Environment variables, single source of truth config file or runtime detection?

Copy link
Collaborator

Choose a reason for hiding this comment

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

i like the idea to use a single source of truth config combined with nconf. This way the default value that stored in the config file can be overwritten by setting some env variables.
https://www.npmjs.com/package/nconf/

Copy link
Collaborator

@bogy0 bogy0 Nov 13, 2025

Choose a reason for hiding this comment

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

@rodet FYI pushed change that resolves your review feedback:
Since the Express server serves both the API routes and the React app on the same origin, we can simply use relative URLs here.
i believe this converstaion can be resolved, but its your call.

Copy link
Contributor

@rodet rodet left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @bogy0 . Let's first discuss the findings before merging this.

Mikadv and others added 11 commits November 13, 2025 20:16
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
…stency

also removed unnecessary console.log

Resolves: no-ticket
Signed-off-by: [Balint Lendvai] <[email protected]>
… environments in message API functions

Resolves: no-ticket
Signed-off-by: [Balint Lendvai] <[email protected]>
…lanation

- Updated layout to improve readability and added a detailed explanation of the data fetching process.
- fixed posts responsive behaviour in mobile size
- Removed unnecessary styles from the dynamic message section paragraphs.

Resolves: no-ticket
Signed-off-by: [Balint Lendvai] <[email protected]>
- Handled review comments
- Changed error handling to set comments state correctly on failure.
- Enhanced layout by introducing Stack components for better spacing and readability.
- Updated paragraph elements for post body and comments for consistency.

Resolves: no-ticket
Signed-off-by: [Balint Lendvai] <[email protected]>
- Removed hardcoded localhost URLs for fetching posts and comments.
- removed unused eslint-disabled directive import/namespace

Resolves: no-ticket
…package-lock.json

- Cleaned up package-lock.json by removing unnecessary 'peer' properties from various dependencies.
- This was done automatically by npm after i run a fresh npm install

Resolves: no-ticket
Signed-off-by: [Balint Lendvai] <[email protected]>
@bogy0 bogy0 force-pushed the feat/network-query-examples branch from b8de01b to 52387ff Compare November 13, 2025 19:26
@bogy0
Copy link
Collaborator

bogy0 commented Nov 13, 2025

FYI @rodet and @lee-chase , i had to force-push after rebasing this branch with latest main.

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.

4 participants