API

  • 1. Step
    Complete code
    
    
              export default function About() {
              const callAPI = async () => {
                try {
                  const res = await fetch(
                    `https://jsonplaceholder.typicode.com/posts/1`
                  );
                  const data = await res.json();
                  console.log(data);
                } catch (err) {
                  console.log(err);
                }
              };
              return (
                <div >
                  <main >
                    <button onClick={callAPI}>Make API Call</button>
                  </main>
                </div>
              );
            }