Error returns the message as an array instead of a string
this is my api response
but when i call the following function
the
i'm using nextjscrud dataprovider and useCreate mutation
{"statusCode":400,"message":"This name is already taken","error":"Bad Request","errors":{"name":["This name is already taken"]}}{"statusCode":400,"message":"This name is already taken","error":"Bad Request","errors":{"name":["This name is already taken"]}}but when i call the following function
async function onSubmit(values) {
try {
await mutate(
{ values },
{
onError: (error) => {
//TODO: Handle error with notifcationprovider
console.log(error)
},
onSuccess: (data) => {
setOpen(false)
router.push(
`/groups/${data?.data?.id}`,
)
},
},
)
} catch (error) {
//TODO: Handle error with notifcationprovider
console.error(error)
}
} async function onSubmit(values) {
try {
await mutate(
{ values },
{
onError: (error) => {
//TODO: Handle error with notifcationprovider
console.log(error)
},
onSuccess: (data) => {
setOpen(false)
router.push(
`/groups/${data?.data?.id}`,
)
},
},
)
} catch (error) {
//TODO: Handle error with notifcationprovider
console.error(error)
}
}the
onErroronError returns {
"statusCode": 400,
"message": "Bad Request",
"errors": {
"": [
"T",
"h",
"i",
"s",
" ",
"n",
"a",
"m",
"e",
" ",
"i",
"s",
" ",
"a",
"l",
"r",
"e",
"a",
"d",
"y",
" ",
"t",
"a",
"k",
"e",
"n"
]
}
}{
"statusCode": 400,
"message": "Bad Request",
"errors": {
"": [
"T",
"h",
"i",
"s",
" ",
"n",
"a",
"m",
"e",
" ",
"i",
"s",
" ",
"a",
"l",
"r",
"e",
"a",
"d",
"y",
" ",
"t",
"a",
"k",
"e",
"n"
]
}
}i'm using nextjscrud dataprovider and useCreate mutation
