Can not update field

I want to update a field when a user clicks the specific image. I added an onClick method to the image, and the function is below.

I got a space.getEntry not a function error at the end.

client.getSpace(‘x18qe0iaxip2’).then((space) => space.getEntry(‘favorited’))
.then((entry) => {
entry.fields.favorited = true
return entry.update()
.then(entry => console.log(entry.fields.favorited))

I would confirm you are using the content management API and not the content delivery API. The content delivery API cannot update entries.

If you are using the correct API make sure ‘favorited’ is a valid entry id and that you don’t have to specify a locale ie entry.fields.favorited['en-US'] = true.

Hope that helps!