I'm running a nuxt 3 app with a simple form. Form submissions are posted to directus, using the directus SDK. I've created a server route to do these post calls server side. And they work, hooray.
Now, in my directus collection, there are some fields that need to be unique. i.e email and phone number.
But let's say i create a form submission with the value of these fields not unique, only the first field error will show up in the server response. It's always one error.
Am I missing something or is this a bug?
A very simplistic representation of my code below with a postObject that is already in my collection:
postObject: {
email: "[email protected]",
phone: "12345"
}
export default defineEventHandler(async (event) => {
const { postObject } = await readBody(event);
try {
return await directus.request(
createItem(COLLECTIONS.NAME_OF_COLLECTION, postObject),
);
} catch (e) {
// e.errors will show an array of just one item
console.log(e.errors);
}
});
The directus docs are not really helping with error handling.
There has been an update to error handling in the directus SDK recently, but it doesn't mention this problem.