Generate a random user

There are many cases on which you need a random user information for testing purposes or just to mock some data.

Yesterday I was on the NonDutch company meeting, and my colleague and friend Prashant show us a Chrome DevTools snippet that gets a random user.

I got curious and I decided to research, and then I found the RandomUser.me.

They call themselves as a Like Lorem Ipsum, but for people.

The best part is that this service is free of charge, and Open Source

They even have a Photoshop Extension if you are a designer and you want to mock people.

For the API it's simple to use.

Just do a GET https://randomuser.me/api/ and get a beatiful JSON with the information of your mocked user...

If you need to do in Javascript, you can use the new fetch() api, and I leave you a snippet that does the job and logs it on your browser console:

fetch('https://randomuser.me/api/')  
  .then(res => res.json())
  .then(res => { console.log(res.results[0]) });

If you run it on the console, you'll get this object:

I hope you enjoyed, and thanks Prashant for sharing it!