mirror of
https://github.com/coder/code-server.git
synced 2026-05-06 12:31:58 +02:00
21 lines
899 B
TypeScript
21 lines
899 B
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
|
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
|
import { isWeb } from 'vs/base/common/platform';
|
|
|
|
if (isWeb) {
|
|
CommandsRegistry.registerCommand('_workbench.fetchJSON', async function (accessor: ServicesAccessor, url: string, method: string) {
|
|
const result = await fetch(url, { method, headers: { Accept: 'application/json' } });
|
|
|
|
if (result.ok) {
|
|
return result.json();
|
|
} else {
|
|
throw new Error(result.statusText);
|
|
}
|
|
});
|
|
}
|