I check API endpoints using POSTMAN. But its post HTTP method is not working properly

I check API endpoints using POSTMAN. But its post HTTP method is not working properly. This is the user login backend code. Get data from the mongo DB database and validated the user login. After validating user can easily log in to the system. This is the User Dao.js file. userDAO.js const user = require(‘./index’).db("newDb").collection("user");… Read More I check API endpoints using POSTMAN. But its post HTTP method is not working properly

how to enable cros origin in koajs

how to enable cros origin in koajs implement cors Access to XMLHttpRequest at ‘http://localhost:3000/course’ from origin ‘http://localhost:1234’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. >Solution : npm init npm i koa npm i nodemon –save-dev npm i @koa/router npm i koa-bodyparser npm i @koa/cors npm i dotenv… Read More how to enable cros origin in koajs

connecting koa js backend with parcel front

Item Model.js const mongoose = require("mongoose") const ItemSchema = new mongoose.Schema({ itemId: {type:String, required: true}, itemName : {type: String, required: true}, }) const Item = mongoose.model("items", ItemSchema); module.exports = Item; ItemController.js file here you have the apiis const Item = require("../Models/ItemModel"); add item function in here used itemId and Item Name const addItem = async(ctx)=>{… Read More connecting koa js backend with parcel front

in these functions error message is not showing in runtime

const Course = require("../models/course.model"); In here code is usually working but when it facing an error it wont show proper error message in run time also it didnt show error in the console const addCourse = async(ctx) => { try { console.log(ctx.request.body); const {courseName, courseFee, students} = ctx.request.body; const course = await Course.create({ courseName, courseFee,… Read More in these functions error message is not showing in runtime

How to save data as int using mongodb compass and koa js. Value automatically convert into String

I am creating a simple CRUD application using mongodb compass and koa js. This is the dao file I am using const products = require(‘./index’).db(‘store’).collection(‘products’); const ObjectId = require(‘mongodb’).ObjectId; const save = async ({name, description,qty,price}) => { const result = await products.insertOne({name, description,qty,price}); return result; } const getAll = async () => { const cursor… Read More How to save data as int using mongodb compass and koa js. Value automatically convert into String