Whenever I try to add a new record in my Collection-Type, all the field values are successfully added to the new entry except for the value in the field with a Relation type.
For instance, in my event Collection-Type, I have fields like name, performers, venue, address, date, time, description, and user.
The 'user' field is of Relation type (Relation with User (from:users-permission)).
All other fields are Text, DateTime, RichText, etc.
After receiving data from the form submission, the object looks similar to this:
var values = {
name: 'namevalue',
performers: 'whatever',
venue: 'whatever',
address: 'xyz address',
date: '2022-12-15',
time: '10:00 PM',
description: 'Description of the Event',
}
I simply update the 'values' object as follows:
var values = {
name: 'namevalue',
performers: 'whatever',
venue: 'whatever',
address: 'xyz address',
date: '2022-12-15',
time: '10:00 PM',
description: 'Description of the Event',
user:1
}
PLEASE NOTE the user:1
that has been added to the object above.
However, after submitting these values to the appropriate endpoint:
const res = await fetch(`${API_URL}/api/events`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`,
},
body: JSON.stringify({
data: values,
}),
})
In the Strapi backend, the 'user' field and its value do not appear at all. Here's an example of what I receive:
{
data: {
name: '13',
performers: '13',
venue: '13',
address: '13',
date: '2022-06-10',
time: '8:00 PM',
description: '13'
},
files: undefined
}
As seen, all the other data is received and saved into the new Entry except for the desired Relation value. What am I overlooking here and how can I resolve this issue?