Been stuck on this over an hour or two now >.<
I am unable to access the request body for the user api. I can get the response ‘hi’ back using res.send (see screenshot) but not with any req.body values. Email is coming back undefined :/
Any ideas where I am going wrong?
Content type is set to json on the postman headers.
Controller:
import asyncHandler from 'express-async-handler'
const authUser = asyncHandler(async (req, res) => {
const { email, password } = req.body
res.send('hi' + email)
})
export {authUser}
Route:
import express from 'express'
const router = express.Router()
import { authUser } from '../controllers/userController.js'
router.post('/login', authUser)
export default router
hiundefined ^
Server.js
import express from 'express'
import dotenv from 'dotenv'
import connectDB from './config/db.js'
import productRoutes from './routes/productRoutes.js'
import userRoutes from './routes/userRoutes.js'
import colours from 'colours'
import { notFound, errorHandler} from './middleware/errorMiddleware.js'
dotenv.config()
connectDB()
const app = express()
app.use(express.json())
app.get('/', (req, res) => {
res.send('API is running...')
})
app.use('/api/products/', productRoutes)
app.use('/api/users/', userRoutes)
app.use(notFound)
app.use(errorHandler)
const PORT = process.env.PORT || 5000
app.listen(
PORT,
console.log(`Server running in ${process.env.NODE_ENV} mode on port ${PORT}`.yellow.bold)
)
prednisone 250 mg – prednisone for sale in canada prednisone otc
modafinil adhd – buy provigil provigil generic
accutane 10mg for sale – accutane drug price accutane canada cost
vardenafil dosage 40 mg – buy vardenafil from canada vardenafil 10 pills
where to buy ivermectin pills – price of ivermectin ivermectin 6mg dosage
buy cialis online in india – tadalafil 10mg australia pharmacy website
ivermectin 15 mg – ivermectin lotion for lice
buy accutane australia – accutane online for sale accutane coupon
lyrica cheap online – cheap viagra canadian pharmacy canadian pharmacy generic viagra
amoxicillin sleep – amoxil buy amoxicilina 500 mg online
sildenafil 50mg price – 200 mg viagra online cost of viagra generic
prednisone drug – prednisone for tinnitus prednisone 10 mg
generic provigil – site modafinil 100 mg
zithromax pack – buy zithromax cheap buy zithromax 250mg online
lasix for sale online – lasix over the counter 20mg lasix without prescription usa
clomid otc – clomiphene online clomid coupons
where to buy misoprostol online – cytotec singapore pharmacy cytotec 200
doxycycline canada price – how to get doxycycline cheap doxycycline 100mg cap price
120 mg accutane daily – where to get accutane in singapore buy accutane cream
generic amoxil – amoxicilin usa antibiotics without a doctor’s prescription
doxycycline capsules 50mg 100mg – prednisolone for sale uk methyl prednisolone
prednisone for sale without a prescription – prednisone from india prednisone 5 mg brand name
casino online games for real money – casino real money real money casino
ivermectin uk – modafinil 100mg oral buy liquid ivermectin