UNPKG

827 BJavaScriptView Raw
1import {storiesOf} from '@storybook/html';
2
3import hubConfig from '../../.storybook/hub-config';
4import Auth from '../auth/auth';
5import HTTP from '../http/http';
6
7
8storiesOf('Utilities|HTTP service', module).
9 addParameters({
10 notes: 'Provides a way to perform authorized network requests.',
11 hermione: {skip: true}
12 }).
13 add('basic', () => {
14 const node = document.createElement('div');
15 node.innerHTML = '<div id="output">Fetching user using HTTP service...</div>';
16
17 const auth = new Auth(hubConfig);
18 const http = new HTTP(auth);
19
20 (async function initializeExample() {
21 await auth.init();
22
23 const user = await http.get(`${hubConfig.serverUri}/api/rest/users/me?fields=name,login`);
24
25 node.querySelector('#output').innerText = JSON.stringify(user);
26 }());
27
28 return node;
29 });