@equinor/mad-core
Version:
Core library for the Mobile App Delivery team
31 lines (28 loc) • 1.01 kB
JavaScript
import {
getMadCommonBaseUrl,
getMadCommonScopes
} from "./chunk-ZB37EIZB.js";
import {
__async
} from "./chunk-CWMXXUWU.js";
// src/components/screens/create-incident/createIncident.ts
import { authenticateSilently } from "@equinor/mad-auth";
var createIncident = (data, env, serviceNow) => __async(void 0, null, function* () {
const baseUrl = getMadCommonBaseUrl(env);
const scopes = getMadCommonScopes(env);
const authenticationResponse = yield authenticateSilently(scopes);
if (!authenticationResponse) throw new Error("Unable to authenticate silently");
const fetchResponse = yield fetch(`${baseUrl}/ServiceNow/apps/${serviceNow}/incidents`, {
method: "POST",
body: JSON.stringify(data),
headers: new Headers({
Accept: "application/json",
"Content-Type": "application/json",
Authorization: `Bearer ${authenticationResponse.accessToken}`
})
});
return yield fetchResponse.json().then((result) => JSON.parse(result));
});
export {
createIncident
};