JSFiddle - React, Tailwind, and code Playground

HTML

<button id="mioBottone">
  Mio bottone
</button>

<input id="inputFile" type="file" accept="xlsx" />

JavaScript

setTimeout(function () {
	console.log("I'm in setTimeo function!");
	document.getElementById("inputFile").click();
}, 3000);

document.getElementById("mioBottone").addEventListener("click", function () {
	callAPI()
  	.then(function (data) {
    	console.log("I'm in then function!");
      document.getElementById("inputFile").click();
    });
});

function callAPI () {
	return new Promise (function (resolve, reject) {
  	$.get( "https://swapi.co/api/people/1/", function( data ) {
      resolve(data);
    });
  });
}