const url = localhost:4000/api/users/register; const usersData= []; let getData = () => { axios.get(url) .then(res => usersData.push(res.data)) .catch(err => console.log(err.data)) }