Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
formPost(url, body, params) {
params = params || {};
this.beforeRequest(params);
this.onBeforeRequest(params);
return http.post(this.url + url, body, params);
}
export default (token) => {
const url = `${FROST_HOST}/tokens`
const params = { headers: { 'Content-Type': 'application/json', token } }
const res = http.post(url, {}, params)
check(res, {
'status 200': (r) => r.status === 200
})
sleep(1)
}
export default ({ token, work }) => {
const url = `${FROST_HOST}/works`
const params = { headers: { 'Content-Type': 'application/json', token } }
const res = http.post(url, work, params)
check(res, {
'status 200': (r) => r.status === 200
})
sleep(1)
}
post(variables = {}) {
const res = http.post('http://localhost:3000/shop-api/', {
query: this.document,
variables: JSON.stringify(variables),
}, {
timeout: 120 * 1000,
});
check(res, {
'Did not error': r => r.json().errors == null && r.status === 200,
});
const result = res.json();
if (result.errors) {
fail('Errored: ' + result.errors[0].message);
}
return res.json();
}
}
export default () => {
const email = `user${Date.now()}+${__VU}@po.et`;
const payload = JSON.stringify({ email, password: 'aB%12345678910' })
const url = `${FROST_HOST}/accounts`
const params = { headers: { 'Content-Type': 'application/json' } }
const res = http.post(url, payload, params)
check(res, {
'status 200': (r) => r.status === 200
})
sleep(1)
}
export default function () {
let res = http.post(configuration.url, configuration.payload, configuration.params);
check(res, {
"status was 200": (r) => r.status == 200,
"transaction time OK": (r) => r.timings.duration < 200
});
sleep(1);
};
const createEncounter = (patientId) => {
encounterResource.patient.reference = `Patient/${patientId}`
const response = http.post(
`${BASE_URL}/fhir/Encounter`,
JSON.stringify(encounterResource),
{
headers: {
Accept: 'application/json',
'Content-Type': 'application/json+fhir'
},
tags: {
name: 'Create Encounter Resource'
}
}
)
check(response, {
'status code for encounter create is 201': r => r.status === 201
})
function makePostRequest() {
const response = http.post(
`${BASE_URL}/mediator`,
'{"hello": "world"}',
{
headers: {
Accept: 'application/json',
Authorization: 'Basic cGVyZm9ybWFuY2U6cGVyZm9ybWFuY2U=',
'Content-Type': 'application/json'
},
tags: {
name: 'Post request'
}
}
)
check(response, {
'status code is 200': r => r.status === 200
})
const createObservation = (observation, patientId, encounterId) => {
observation.context.reference = `Encounter/${encounterId}`
observation.subject.reference = `Patient/${patientId}`
const response = http.post(
`${BASE_URL}/fhir/Observation`,
JSON.stringify(observation),
{
headers: {
Accept: 'application/json',
'Content-Type': 'application/json+fhir'
},
tags: {
name: `Create Observation Resource`
}
}
)
check(response, {
'status code for observation create is 201': r => r.status === 201
})
function getToken(clientId, clientSecret) {
const tokenUrl = `${variables.serverUrl}/identity-server/connect/token`;
const tokenResponse = http.post(tokenUrl, {
grant_type: 'client_credentials',
client_id: clientId,
client_secret: clientSecret,
scope: 'squidex-api'
}, {
responseType: 'text'
});
if (tokenResponse.status !== 200) {
throw new Error('Invalid response.');
}
const tokenJson = JSON.parse(tokenResponse.body);
return tokenJson.access_token;
}