mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-07 08:34:15 +01:00
add decomment step in a try catch block (#2485)
* add decomment step in a try catch block * request params validation - fix unit tests
This commit is contained in:
parent
929d2b5299
commit
b031e1f009
@ -76,10 +76,15 @@ const prepareRequest = (request, collectionRoot) => {
|
||||
if (!contentTypeDefined) {
|
||||
axiosRequest.headers['content-type'] = 'application/json';
|
||||
}
|
||||
const jsonBody = decomment(request.body.json);
|
||||
let jsonBody;
|
||||
try {
|
||||
jsonBody = decomment(request?.body?.json);
|
||||
} catch (error) {
|
||||
jsonBody = request?.body?.json;
|
||||
}
|
||||
try {
|
||||
axiosRequest.data = JSONbig.parse(jsonBody);
|
||||
} catch (ex) {
|
||||
} catch (error) {
|
||||
axiosRequest.data = jsonBody;
|
||||
}
|
||||
}
|
||||
|
@ -172,11 +172,16 @@ const prepareRequest = (request, collectionRoot, collectionPath) => {
|
||||
if (!contentTypeDefined) {
|
||||
axiosRequest.headers['content-type'] = 'application/json';
|
||||
}
|
||||
const body = decomment(request.body.json);
|
||||
let jsonBody;
|
||||
try {
|
||||
axiosRequest.data = JSONbig.parse(body);
|
||||
} catch (ex) {
|
||||
axiosRequest.data = body;
|
||||
jsonBody = decomment(request?.body?.json);
|
||||
} catch (error) {
|
||||
jsonBody = request?.body?.json;
|
||||
}
|
||||
try {
|
||||
axiosRequest.data = JSONbig.parse(jsonBody);
|
||||
} catch (error) {
|
||||
axiosRequest.data = jsonBody;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user