-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathclient.ts
34 lines (31 loc) · 980 Bytes
/
client.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { URLExt } from '@jupyterlab/coreutils';
import { ServerConnection } from '@jupyterlab/services';
import { Constants } from './constants';
class JupyterlabCodeFormatterClient {
public request(path: string, method: string, body: any): Promise<any> {
const settings = ServerConnection.makeSettings();
const fullUrl = URLExt.join(settings.baseUrl, Constants.PLUGIN_NAME, path);
return ServerConnection.makeRequest(
fullUrl,
{
body,
method
},
settings
).then(response => {
if (response.status !== 200) {
return response.text().then(() => {
throw new ServerConnection.ResponseError(
response,
response.statusText
);
});
}
return response.text();
});
}
public getAvailableFormatters(cache: boolean) {
return this.request('formatters' + (cache ? '?cached' : ''), 'GET', null);
}
}
export default JupyterlabCodeFormatterClient;