JSFiddle - React, Tailwind, and code Playground

by Sergey Linnick

JavaScript

const createUsers = async (users = []) => {
	const newArr = [];

  
  for (const user of users) {
  	const item = await fetch('https://jsonplaceholder.typicode.com/users', {
      method: 'POST',
      body: JSON.stringify({
        name: user.name,
        age: user.age,
      }),
      headers: {
        "Content-type": "application/json; charset=UTF-8"
      }
    }).then((response) => response.json());
    
    newArr.push(item);
  }
  
  console.log(newArr, newArr.length);
	
}

createUsers([{
  name: 'Vasya',
  age: 25
}, {
  name: 'Petya',
  age: 40
}]);