Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async herokuAction(
endpoint: string,
method: string = "POST",
data: Object = {}
): Promise {
const path = this.getCurrentPath();
const request = httpRequest(endpoint, method, {
current_path: path,
...data
});
const response = await request;
if (!response.ok) {
const data = await response.json();
throw new ServerConnection.ResponseError(response, data.message);
}
return response.json();
}
return response.text().then(data => {
throw new ServerConnection.ResponseError(response, data);
});
}
async getPackagingIntegrations(
credentials: ICloudCredentials
): Promise> {
let response = await httpRequest(
URLs.cloudPackagingIntegrationUrl,
'GET',
null,
credentials
);
if (response.status !== 200) {
const data = await response.json();
throw new ServerConnection.ResponseError(response, data.message);
}
return response.json();
}
return response.json().then((data) => {
throw new ServerConnection.ResponseError(response, data.message);
});
}
async removeCloudTraining(
request: models.IRemoveRequest,
credentials: ICloudCredentials
): Promise {
let response = await httpRequest(
URLs.cloudTrainingsUrl,
'DELETE',
request,
credentials
);
if (response.status !== 200) {
const data = await response.json();
throw new ServerConnection.ResponseError(response, data.message);
}
return null;
}
export function makeError(
code: number,
message: string
): ServerConnection.ResponseError {
const response = new Response(message, { status: code, statusText: message });
return new ServerConnection.ResponseError(response, message);
}
async getModelTrainings(
credentials: ICloudCredentials
): Promise> {
let response = await httpRequest(
URLs.cloudTrainingsUrl,
'GET',
null,
credentials
);
if (response.status !== 200) {
const data = await response.json();
throw new ServerConnection.ResponseError(response, data.message);
}
return response.json();
}