I need advice how to solve when I need for one route 2x PUT request. I need to add and remove 2 kinds of inputs. But I can remove one or the other. I can’t figure out a way to set route.js to be able to add and remove both kinds of inputs.
<code>> export async function PUT(request) {
> const id = request.nextUrl.searchParams.get("id");
> const result = await CargoDetails.findOneAndUpdate(
> {
> $and: [{ _id: id }],
> },
> {
> $push: { defaultValues: { count: "", long: "", width: "", weight: "", high: "" },
> },
> },{ new: true }
> );
>
> return NextResponse.json({ result }, { status: 200 });
> }
</code>
<code>> export async function PUT(request) {
> const id = request.nextUrl.searchParams.get("id");
> const result = await CargoDetails.findOneAndUpdate(
> {
> $and: [{ _id: id }],
> },
> {
> $push: { defaultValues: { count: "", long: "", width: "", weight: "", high: "" },
> },
> },{ new: true }
> );
>
> return NextResponse.json({ result }, { status: 200 });
> }
</code>
> export async function PUT(request) {
> const id = request.nextUrl.searchParams.get("id");
> const result = await CargoDetails.findOneAndUpdate(
> {
> $and: [{ _id: id }],
> },
> {
> $push: { defaultValues: { count: "", long: "", width: "", weight: "", high: "" },
> },
> },{ new: true }
> );
>
> return NextResponse.json({ result }, { status: 200 });
> }
<code>> export async function PUT(request) {
> const id = request.nextUrl.searchParams.get("id");
> const result = await CargoDetails.findOneAndUpdate(
> {
> $and: [{ _id: id }],
> },
> {
> $push: { exwork: { cost: "" },
> },
> },{ new: true }
> );
>
> return NextResponse.json({ result }, { status: 200 });
> }
</code>
<code>> export async function PUT(request) {
> const id = request.nextUrl.searchParams.get("id");
> const result = await CargoDetails.findOneAndUpdate(
> {
> $and: [{ _id: id }],
> },
> {
> $push: { exwork: { cost: "" },
> },
> },{ new: true }
> );
>
> return NextResponse.json({ result }, { status: 200 });
> }
</code>
> export async function PUT(request) {
> const id = request.nextUrl.searchParams.get("id");
> const result = await CargoDetails.findOneAndUpdate(
> {
> $and: [{ _id: id }],
> },
> {
> $push: { exwork: { cost: "" },
> },
> },{ new: true }
> );
>
> return NextResponse.json({ result }, { status: 200 });
> }
I know that that maybe is it not possible to do it this way. I’d be grateful for any advice. Thank you.