Submitted by Andrew on Mon, 07/17/2017 - 12:05

How do you edit node fields from a rest endpoint?

https://www.drupal.org/docs/8/core/modules/rest/4-patch-for-updating-content-entities

 

I don't have the HAL module enabled yet, so this example isn't quite right for me.  Also I'm using VUE, which is going to look a little different in the code.

 

Here's what I went with:

      this.$http({url: scoreURL, method: 'PATCH', body: '{"type": "score", "field_score":[{"value":98}]}', headers: {
        "Content-Type": 'application/json',
        "X-CSRF-Token": 'ZOVGyUosH3ALqIJtZPDJmDUs6KOYzV_Ccc0fySSBvTA',
      }}).then(function() {
        alert('win');
      }, function() {
        alert('fail');
      });

 

The token is obtained from /rest/session/token.

It looks like there's another way to set the headers:
https://github.com/pagekit/vue-resource/blob/master/docs/http.md#interceptors

What is the difference between props and data?
https://vuejs.org/v2/examples/grid-component.html

 

 

Subject
Resources