Skip to content

Commit

Permalink
Check response in Swimlane
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Oct 20, 2021
1 parent ce7df44 commit 6fd2cdc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ export const throwIfRequestIsNotValid = ({
requiredAttributesToBeInTheResponse?: string[];
}) => {
const requiredContentType = 'application/json';
const contentType = res.headers['content-type'];
const contentType = res.headers['content-type'] ?? '';
const data = res.data;

/**
* This check ensures that the response is a valid JSON.
* First we check that the content-type of the response is application/json.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Logger } from '@kbn/logging';
import axios from 'axios';

import { ActionsConfigurationUtilities } from '../../actions_config';
import { getErrorMessage, request } from '../lib/axios_utils';
import { getErrorMessage, request, throwIfRequestIsNotValid } from '../lib/axios_utils';
import { getBodyForEventAction } from './helpers';
import {
CreateCommentParams,
Expand Down Expand Up @@ -89,6 +89,12 @@ export const createExternalService = (
method: 'post',
url: getPostRecordUrl(appId),
});

throwIfRequestIsNotValid({
res,
requiredAttributesToBeInTheResponse: ['id', 'name', 'createdDate'],
});

return {
id: res.data.id,
title: res.data.name,
Expand Down Expand Up @@ -124,6 +130,11 @@ export const createExternalService = (
url: getPostRecordIdUrl(appId, params.incidentId),
});

throwIfRequestIsNotValid({
res,
requiredAttributesToBeInTheResponse: ['id', 'name', 'modifiedDate'],
});

return {
id: res.data.id,
title: res.data.name,
Expand Down

0 comments on commit 6fd2cdc

Please sign in to comment.