I have this Next.js app where I’m using Strapi as a CMS
In Strapi I have a collection called Events
the Event content type has a field which is a relation many to many with the collection Checklist
the Checklist collection has items in it like:
{
Title: flyers (text),
Ok: false (boolean)
}
where each item is just a Title and boolean value
so that for each Event frontend I have a checklist of names with a checkbox, like:
☐ flyers
☐ merch
☐ emails
how do I update the boolean value via Strapi put api call? documentation in this sense is non existent
it says you need to use the item id, thanks, that’s a 10% of the job here, anyone had this done before perhaps?
in my Next.js api file right now I was trying something like this (where 3 is the ID
of the Event and 3 is the ID
of the Checklist item):
import { NextResponse } from 'next/server'
import axios from 'axios'
const strapiUrl = process.env.STRAPI_BASE_URL
export async function POST(req) {
const { isChecked } = req.body;
try {
await axios.put(`${strapiUrl}/api/checklist/3/3/Ok`, {
isChecked,
});
return NextResponse.json({
success: `ok`
},{status: 250});
}catch (error){
return NextResponse.json({
success: `Probable error`
});
}
}
but I’m working blindly here, it doesn’t work and I have no idea why or how should it be to be honest, nowhere in their documentation to be found