This is supposed to have the data from a different POST route assigned to it, and it makes the data accessible via GET. 2 different routes, 1 sharing data with the other.
import mongoose, { SchemaTypes } from "mongoose";
import { IPlan } from "./Plan";
interface IPlanDetails extends IPlan {
status: "Processing" | "Active" | "Expired" | "Declined" | "Refunded";
}
const PlanDetailsSchema = new mongoose.Schema<IPlanDetails>({
planName: SchemaTypes.ObjectId,
status: {
type: String,
default: "Processing",
enum: {
values: ["Processing", "Active", "Expired", "Declined", "Refunded"],
message: "{VALUE} is not supported",
},
},
});
export default mongoose.model<IPlanDetails>("PlanDetails", PlanDetailsSchema);
import { Request, Response } from "express";
import PlanDetails from "../models/PlanDetails";
export const getPlanDetails = async (req: Request, res: Response) => {
const planDetails = await PlanDetails.find({});
res.status(200).json({ planDetails });
};
The current output is
{
"planDetails": []
}
It doesn’t output the data which should have been shared with it and it doesn’t output the default.