acquia / waterwheel.js

A generic JavaScript helper library to query and manipulate Drupal 8 via core REST and JSON API
https://github.com/acquia/waterwheel.js
233 stars 26 forks source link

Drupal's 403 responses now contain the reason for denying access — expose that! #53

Closed wimleers closed 6 years ago

wimleers commented 7 years ago

Title says it all :)

See https://www.drupal.org/node/2808233.

Definitely works for rest in Drupal 8.3 core. Should also work for the jsonapi contrib module for sites using Drupal 8.3.

mattgrill commented 7 years ago

@wimleers This is a great DX improvement. There's an issue with JSON API currently nullifying these error messages, #2852691. However if you don't have JSON API enabled the messages come back already. 😄

waterwheel.populateResources('/water-wheel/swagger/entities?_format=json')
  .then(() => waterwheel.getAvailableResources())
  .then(() => waterwheel.api['node:article'].get(251))
  .then(console.log)
  .catch(err => {
    /*
      {
        message: 'The used authentication method is not allowed on this route.',
        status: 403
      }
    */
  });
wimleers commented 7 years ago

https://www.drupal.org/node/2852691 was fixed a few weeks ago :)

mattgrill commented 7 years ago

@wimleers Great. I can test this again. I suspect that it will behave correctly already :)

mattgrill commented 6 years ago

Alright. This should have been closed a while ago. Waterwheel will automatically capture the error message from Drupal and forward on the result.