import axios from "axios";
import { useEffect, useState } from "react";
import "./styles.css";
export default function App() {
// let arr = [A, B, C];
const [item, setItem] = useState([]);
useEffect(() => {
axios.get("https://swapi.dev/api/planets/?page=2").then((item) => {
console.log(item);
setItem(item.data.results);
});
}, []);
return (
<div className="App">
<ul>
{item.map((planet) => {
return <li>{planet.name}</li>;
})}
</ul>
</div>
);
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter