NextJS 13 and React Crash Course: Build a Full Stack NextJS 13 App with React, Tailwind and Prisma backend by Lim Greg

NextJS 13 and React Crash Course: Build a Full Stack NextJS 13 App with React, Tailwind and Prisma backend by Lim Greg

Author:Lim, Greg
Language: eng
Format: epub
Published: 2023-08-20T00:00:00+00:00


Code Explanation

In this component, we import 'Link' from 'next/link', as we want to provide a link to each book's Amazon page.

async function getBooks() {

const res = await fetch("http://localhost:3000/api/books");

const json = await res.json();

return json;

}

Next, we'll define an async function getBooks to fetch the books. The endpoint we're fetching from is the one where we have our books, and we'll parse the response as JSON.

const Books = async () => {

const books = await getBooks();

return(

<div>

<h1>Books</h1>

</div>

)

}

Inside the Books component, we'll call getBooks using 'await' since it's asynchronous. Consequently, this part of the code also needs to be labeled as 'async'.

Mapping through the books array

We'll then map through the books array. Each book will be displayed using a 'Card' component from Daisy UI.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
SvelteKit Up and Running by Dylan Hildenbrand(6015)
Building Blazor WebAssembly Applications with gRPC by Václav Pekárek(3548)
Hands-On Application Development with PyCharm by Bruce M. Van Horn II
 Quan Nguyen(2173)
Designing Web APIs with Strapi: Get started with the Strapi headless CMS by building a complete learning management system API by Khalid Elshafie Mozafar Haider(1050)
Django 4 for the Impatient. Learn the core concepts of Python web development with Django in one weekend by G. Lim D. Correa(901)
Vue.js 3 Design Patterns and Best Practices by Pablo David Garaguso(834)
Accelerating Server-Side Development with Fastify by Manuel Spigolon & Maksim Sinik & Matteo Collina(831)
Drupal 10 Module Development - Fourth Edition by Daniel Sipos(754)
Mastering CSS Grid by Thormeier Pascal;(708)
Going the Distance with Babylon.js: Building extensible, maintainable, and attractive browser-based interactive applications using JavaScript by Josh Elster(688)
Simplifying State Management in React Native by Aleksandra Desmurs-Linczewska(601)
Java Memory Management by Maaike van Putten & Seán Kennedy(534)
Hands-On Application Development with Pycharm by II Bruce M. Van Horn;Nguyen Quan;(516)
Joomla!® Explained: Your Step-by-Step Guide (Joanne Romanovich's Library) by Stephen Burge(311)
Python & JavaScript Mastery: 2 Books In 1- Learn And Master Two Powerful Programming Languages by Alex iversion(289)
Beginning Modern JavaScript: A Step-By-Step Gentle Guide to Learn JavaScript for Beginners (Code With Nathan) by Sebhastian Nathan(242)
Understanding JavaScript Promises by Nicholas C. Zakas(229)
Create GUI Applications with Python & Qt6: The hands-on guide to making apps with Python by Martin Fitzpatrick(228)
Programming With Java by Edet Theophilus(224)
NextJS 13 and React Crash Course: Build a Full Stack NextJS 13 App with React, Tailwind and Prisma backend by Lim Greg(211)