React JS

How to Create Signup Page UI in React JS

How to Create Signup Page UI in React JS

Here is code for signup.jsx: import React from ‘react’import {Button, Label, TextInput} from ‘flowbite-react’import { Link } from ‘react-router-dom’ const Signup = () => {  return (    <div className=’ max-w-3xl mx-auto flex flex-col md:flex-row mt-20 gap-3 p-3′>        <div className=’ flex-1 flex items-center justify-center flex-col gap-3′>        <Link to=’/’>    […]

How to Create Signup Page UI in React JS Read More »

How to add a Middleware and a Function to Handle Errors

How to add a Middleware and a Function to Handle Errors?

Write a function in index.js:- app.use((err, req, res, next)=>{    const statusCode=err.statusCode || 500;    const message=err.message || “Internal Server Error”;    res.status(statusCode).json({        success:false,        statusCode,        message    })})   Add “next” parameter in signup function in “auth.controller.js” – Add next in catch –   Create a folder

How to add a Middleware and a Function to Handle Errors? Read More »

How to Hash Password in React JS MERN

How to Hash Password in React JS MERN

Install a package – npm i bcryptjs import it in auth.controller.js – import bcryptjs from ‘bcryptjs’ Add marked two line of code for hash the password – Complete code for auth.controller.js: import User from ‘../models/user.model.js’ import bcryptjs from ‘bcryptjs’ export const signup=async(req, res)=>{ const {username, email, password}=req.body; if(!username || !email || !password || username===” ||

How to Hash Password in React JS MERN Read More »

How to Create a SignUp API in React JS MERN

How to Create a SignUp API in React JS MERN?

Create a route file “auth.route.js” in “routes” folder. auth.route.js: – import express from ‘express’ import { signup } from ‘../controllers/auth.controller.js’; const router=express.Router(); router.post(‘/signup’, signup); export default router; ——- Create a file “auth.controller.js” in “controllers” folder. auth.controller.js: import User from ‘../models/user.model.js’ export const signup=async(req, res)=>{ const {username, email, password}=req.body; if(!username || !email || !password || username===”

How to Create a SignUp API in React JS MERN? Read More »

How to Create a Test API in React JS MERN

How to Create a Test API in React JS MERN

Add below given text in index.js: – app.get(‘/test’, (req, res)=>{ res.json({message:”API is working”}) }) Create a folder “routes” in “api” folder. Create a file “user.route.js” in “routes” folder. Write code in user.route.js – import express from ‘express’ const router=express.Router(); router.get(‘/test’, (req, res)=>{ res.json({message:”API is working”}) ) export default router;   import “user.route.js” in index.js import

How to Create a Test API in React JS MERN Read More »