Last active
August 29, 2015 14:05
-
-
Save ttahmouch/91ec74aef00e0ef4295b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Coast Browser</title> | |
| </head> | |
| <body> | |
| <script src="http://127.0.0.1:8080/ua"></script> | |
| <script> | |
| (function (window) { | |
| window.onload = function () { | |
| /** | |
| * Note: There is only one URL hard-coded within the entire application. | |
| * Links and forms are followed from responses. | |
| */ | |
| var client = hypermedia.Api.enter('http://127.0.0.1:8080/notes', function (error, res) { | |
| console.log(res && res.status === 200 ? res.body : 'failed'); | |
| client.can('createNote').do({ body: { title: 'Something cool.' } }, function (error, res) { | |
| console.log(res && res.status === 201 ? res.body : 'failed'); | |
| client.can('getNotes').do(function (error, res) { | |
| console.log(res && res.status === 200 ? res.body : 'failed'); | |
| client.can('getNote').do({ uri: { id: '0' } }, function (error, res) { | |
| console.log(res && res.status === 200 ? res.body : 'failed'); | |
| client.can('deleteNote').do({ uri: { id: '0' } }, function (error, res) { | |
| console.log(res && res.status === 200 || res.status === 204); | |
| client.can('getNotes').do(function (error, res) { | |
| console.log(res && res.status === 200 ? res.body : 'failed'); | |
| client.can('deleteNote').do({ uri: { id: '0' } }, function (error, res) { | |
| console.log(res && res.status === 200 || res.status === 204); | |
| client.can('getNotes').do(function (error, res) { | |
| console.log(res && res.status === 200 ? res.body : 'failed'); | |
| }); | |
| }); | |
| }); | |
| }); | |
| }); | |
| }); | |
| }); | |
| }, true); | |
| }; | |
| })(window); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment