I am currently working on a project to develop a bot on Blip. There are certain parts where I need to send a request to an API and then use a JavaScript script to extract elements from the JSON response.
The JSON response I received from the API is stored in a variable called requestResponse
:
{
"procedures": [
{
"procedure_code": "00003069",
"procedure_name": "FOLIC ACID",
"procedure_type": "P",
"subgroup": {
"sgroup_composite_code": "03001",
"sgroup_name": "LAB1(0,5)"
}
},
{
"procedure_code": "00003077",
"procedure_name": "URIC ACID",
"procedure_type": "P",
"subgroup": {
"sgroup_composite_code": "03001",
"sgroup_name": "LAB1(0,5)"
}
}
]
}
This variable is passed as a parameter to the following function:
function processRequest(requestResponse) {
let responseObject = JSON.parse(requestResponse);
return responseObject.procedures[0].procedure_name;
};
However, when running this function, I encountered an issue where procedures
is undefined. Any assistance would be greatly appreciated!