Technologies | Getting started | Project | What was learned?
This project was developed using the following technologies:
Clone the project and access the folder
$ git clone https://github.com/eltonsantos/consuming-api.git && cd consuming-api
Follow the steps below
# Install the dependencies
$ npm install
# Start the lite-server
$ npx lite-server
# Frontend
$ npm run start
# Backend
$ npm run dev
For lite-server access: http://localhost:3000 and for front/back access: http://localhost:4567
Simple example of how consuming an API in frontend and backend.🥰
- Iniciar o projeto
npm init -y
- Instalar as dependências
npm i express nodemon cors axios
- Criar uma rota para acessar a API
- Servir a API
- Habilitar o CORS
- Habilitar o nodemon para reiniciar o server
- Utilizar fetch para consumir nossa API backend
- Explicar Promise - Async/Await
- Usar try/catch
- Mostrar a resposta na tela
- Jsonplaceholder
- Usar axios
- Semelhanças entre axios e fetch
- Usar try/catch