We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2c2cdb1 commit 7475f54Copy full SHA for 7475f54
1 file changed
experimental/test-login.js
@@ -44,6 +44,23 @@ if (loggedInUser) {
44
+ '<a href="' + serviceUrl + '/logout">'
45
+ 'LOG OUT'
46
+ '</a>';
47
+
48
+ console.log('Testing a REST request...');
49
+ fetch('/api/profile', { method: 'GET', headers: { 'Content-Type': 'application/json' } })
50
+ .then(function (data) {
51
+ if (data.ok) {
52
+ return data.json();
53
+ } else {
54
+ throw new Error('Server Error: ' + data.statusText);
55
+ }
56
+ })
57
+ .then(function (json) {
58
+ console.log('Request successful:');
59
+ console.log(JSON.stringify(json));
60
61
+ .catch(function (error) {
62
+ console.error('REST request failed: ' + error.toString());
63
+ });
64
} else {
65
// prettier-ignore
66
rootDiv.innerHTML = 'You are not logged in'
0 commit comments