basically im trying to update isVerify
property in a collection but i get 500
error but it actually updates in database, however when i specify all values instead of only isVeify
it doesnt show any error and works too
fetch('http://localhost:80/api/wynikis/1', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
data: {
isVerify: false,
},
}),
})
.then((response) => response.json())
.then((data) => console.log(data))
.catch((error) => console.error('Error:', error));
fetch('http://localhost:80/api/wynikis/1', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
data: {
BarbellDeadlift: 123,
BarbellBenchPress: 123,
BarbellCleanJerk: 213,
BarbellBackSquad: 123,
BarbellFrontSquad: 123,
BarbellSnatch: 123,
KettlebellTGU: 123,
KettlebellPistol: 123,
KettlebellPullUp: 123,
KettlebellSnatch5min: 123,
KettlebellSnatch10min: 123,
KettlebellPress: 123,
isVerify: false,
},
}),
})
.then((response) => response.json())
.then((data) => console.log(data))
.catch((error) => console.error('Error:', error));
the first example throws error 500 but updates the field isVerify
the second example updates without error
but its not an ideal solution to have to get item contents just to pass it to update
i get this error on strapi server:
2024-07-09 19:31:53 [2024-07-09 17:31:53.279] error: Cannot read properties of undefined (reading 'services')
2024-07-09 19:31:53 TypeError: Cannot read properties of undefined (reading 'services')
2024-07-09 19:31:53 at Object.afterUpdate (/opt/app/dist/src/api/wyniki/content-types/wyniki/lifecycles.js:88:47)
2024-07-09 19:31:53 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
2024-07-09 19:31:53 at async modelsLifecyclesSubscriber (/opt/node_modules/@strapi/database/lib/lifecycles/subscribers/models-lifecycles.js:15:5)
2024-07-09 19:31:53 at async Object.run (/opt/node_modules/@strapi/database/lib/lifecycles/index.js:62:11)
2024-07-09 19:31:53 at async Object.update (/opt/node_modules/@strapi/database/lib/entity-manager/index.js:343:7)
2024-07-09 19:31:53 at async Object.update (/opt/node_modules/@strapi/strapi/lib/services/entity-service/index.js:223:18)
2024-07-09 19:31:53 at async Object.<anonymous> (/opt/node_modules/@strapi/strapi/lib/services/entity-service/index.js:417:20)
2024-07-09 19:31:53 at async Object.update (/opt/node_modules/@strapi/strapi/lib/core-api/controller/collection-type.js:84:22)
2024-07-09 19:31:53 at async returnBodyMiddleware (/opt/node_modules/@strapi/strapi/lib/services/server/compose-endpoint.js:52:18)
2024-07-09 19:31:53 at async policiesMiddleware (/opt/node_modules/@strapi/strapi/lib/services/server/policy.js:24:5)
but only field marked as required is isVerify
?
This topic has been created from a Discord post (1260340081156427776) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord