Antonio-Maranhao commented on issue #959: correct initial fetch() of _security 
to use credentials (#929)
URL: https://github.com/apache/couchdb-fauxton/pull/959#issuecomment-323366152
 
 
   @lostnet I agree with you that `{}` is not a safe default. I'd suggest 
adding the error handling anyway though. This way it prevents the user from 
inadvertently wiping out the current permissions since the form starts out 
blank.
   Here's my suggestion:
   
   ```
   return fetch(url, {
       headers: {'Accept': 'application/json' },
       credentials: 'include'
     })
     .then(res => res.json())
     .then(json => {
       if (!json.ok) {
         throw new Error(json.reason);
       }
       dispatch(receivedPermissions(json));
     })
     .catch((err) => {
       FauxtonAPI.addNotification({
         msg: 'Failed to retrieve permissions. Please try again. Reason:' + 
err.message,
         type: 'error'
       });
     });
   ```
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to