Random Users Viewer

Random Users Viewer

Project Description

I have created a simple React App to try out the API provided by https://randomuser.me/. Picture in 3 sizes (large, medium, thumbnail) in the form of the URL, title, first name, last name, city country within the location and email are some of the fields returned in the form of JSON from random user's API. I'm not sure if they have an endpoint for fetching a list of users, although they return the results as a list. To have 10 users, I wrote a loop and I resolve the promise in the last step of the loop. In each step of the loop I fetch a single user and parse it using data as User cast in TypeScript. I created User interface using ChatGPT because it's the fastest way. It made a mistake by not deducing that date of birth or registered date are dates, assuming it's a string instead, but after prompting it corrected itself. The loop:

 .then(data => {
 users.push(data as User);
 if (i === numberOfUsers - 1) {
   resolve(users);
 }
})

And I return users as a promise in the containing service method.

I also used Github Copilot here and it works quite well, but it suggested == equality comparison instead of the recommended ===. That shows that a developer is still needed to supervise AI tools.

Technologies Used

  • Java, TypeScript
  • Spring Boot, React JS