so my code is working with ParseReact.Mutation.AddRelation, here it is:
ParseReact.Mutation.AddRelation({
"className": newRow.className,
"objectId": newRow.id.objectId}, 'groceryRequestRelation',[{
"__type":"Pointer",
"className":"ClassThePointerPointingTo",
"objectId":"ObjectIdOfClassThePointerIsPointingTo"
}]).dispatch()
@naoisegolden you didn't put .dispatch() at the end of the AddRelation so that might be an issue.
Another thing that took me forever to figure out was I was using the wrong objectId within my AddRelation, I should be using the objectId of the class that the pointer is pointing to, but I was using the objectId of the class that the relation belongs to...
If this still doesn't work for you, try the REST way to do this:
var data = {
"groceryRequestRelation":{"__op":"AddRelation",
"objects":
[{
"__type":"Pointer",
"className":"ClassThePointerIsPointingTo",
"objectId":"ObjectIdOfClassThePointerIsPointingTo"
}
]
}
};
var url = "https://api.parse.com";
url += "/1/classes/Classname/objectId";
fetch(url, {
method: 'put',
headers: {
'Accept': 'application/json',
'X-Parse-Application-Id': PARSE_APP_ID,
'X-Parse-REST-API-Key': PARSE_REST_KEY,
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then((response) => {
console.log("inside add relation rest")
console.log(response);
return response.json();
})
.then((responseText) => {
console.log(responseText);
})
.catch((error) => {
console.warn(error);
})
.done();