import React from "react";
import ReactDOM from "react-dom";
import { createRoot } from 'react-dom/client';
import axios from "axios";
const BASEURL = "https://jsonplaceholder.typicode.com/users";
function axiosTest() {
return axios.get(BASEURL).then(response => response.data)
}
function stepTwo(){
axiosTest()
.then(data =>{
var namesArray = data;
//console.log(namesArray);
return namesArray;
})
}
function Component1(){
var array2map = stepTwo();
console.log(array2map);
return(
<div>
{array2map.map(item => <p>item.name</p>)}
</div>
)
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Component1 />);
Why does array2map come back as undefined? That's what it says in the console log and what it says in the error I get as the result of trying to map something undefined. That's my question, I don't know how much more verbose about it I can be, but this site is forcing me to write more.