Its probably an error with my API, but I couldn’t find anything wrong with it at all. Postman just loads forever and never sends the POST, until I click cancel and my API terminal prints:
const {Category} = require('../schemas/category'); // Import the Category model
const express = require('express');
const router = express.Router();
router.get(`/`,async (req, res) => {
const categoryList = await Category.find();
if (!categoryList) {
return res.status(404).json({ message: 'No Categories found or available, or an API error. The website may not be able to access the Categories right now, and you may have to wait for a fix.' });
}
res.send(categoryList);
})
router.post(`/`, async (req, res) => {
let category = new Category({
name: req.body.name,
typeof: req.body.typeof,
payment: req.body.payment,
age: req.body.age,
difficulty: req.body.difficulty,
location: req.body.location,
duration: req.body.duration,
dateNtime: req.body.dateNtime,
skills: req.body.skills,
reoccurring: req.body.reoccurring,
urgency: req.body.urgency,
minimumRating: req.body.minimumRating,
icon: req.body.icon,
color: req.body.color,
})
category = await category.save();
if (!category) {
return res.status(404).json({ message: 'Could not POST. this is likely due to a client error and we suggest you deal with it lmao.' });
}
})
module.exports = router;
And What would I run to send the same request from terminal?
Update: It turns out the POST IS sent, but my API doesn’t recognize so. In MongoDB the Schedule does show up, but both my API and Postman are still waiting, so would it be an API error?