Closed johnreytanquinco closed 6 years ago
You need to create a instance
<html>
<body>
<h1>Waterwheel</h1>
<script src="/waterwheel.js"></script>
<script>
const waterwheel = new Waterwheel({
base: 'http://drupal.d8',
oauth: {
grant_type: 'GRANT-TYPE',
client_id: 'CLIENT-ID',
client_secret: 'CLIENT-SECRET',
username: 'USERNAME',
password: 'PASSWORD',
scope: 'SCOPE'
}
});
waterwheel.api['user'].get(1)
.then(res => {
console.log(res)
// Drupal JSON Object
})
.catch(err => {
// err
}
)
;
</script>
</body>
</html>
@johnreytanquinco
I just tagged v1.3.5
with some additional documentation. Hopefully this helps.
npm install waterwheel
This will install the server copy, which may or may not be what you want depending on your build environment.
I have a Drupal site with waterwheel installed and created a client using the Simple Oauth module to fill in the requirement
I have the needed REST resources method checked under
/admin/config/services/rest
Then I have created a simple webapp using yeoman outside of Drupal directory.It has a gulpfile that makes the site accessible in the browser by issuing this command:
$ gulp serve
.I do a
$ npm install waterwheel
and it installed inside the folder directory.I also included the waterwheel.js in the html file:
Now when I try to include the command below to test it is properly working.
I am getting this error message from the browser console and it links to the .get line.
Uncaught TypeError: Cannot read property 'get' of undefined