How to handle api respnose

I am trying to make an api call, store it in a variable named response and then use the response in another node. After making the api call the response is not being saved.

as you can see in the third image the school name is not being shown

any help would be greatly appreciated

From the API response, in a function resolve as

let {apiResponse} = ymLib.args;
let {school} = apiResponse;

Store it in a variable school.

In text UI, access it as {{{}}}

Thank you.

the response from the api is
“statuscode”: “test”
“school”: “test”

let {school} = apiResponse;
would take the value of school from property school.

I would like to store all the values that are coming in response and use them in different nodes. I want the response to be stored as an object

let {apiResponse} = ymLib.args;
let {something1, something2, something3} = apiResponse;
resolve({something1, something2, something3});

Store it in object named as example: obj
Then use it as {{{variables.obj.something1}}} from UI

I really appreciate your patience Subhrajit, I am new to, so please bear with me.

so my final function looks like this, if I want to use only school?
Screenshot 2023-05-12 at 2.02.12 PM

and for using the variable I must use {{{}}}?

but still I am not getting the result

variables.variable_name gets you the variable.
If its an object then you write variables.<variable_name>.<property_name>

here I am storing a variable to school so it should be {{{}}}?

Yes, if its a string type.

yes it is string type. then why is the data being shown?

why is the data being shown → where is data shown?

my bad, why is data not being shown

Make sure that you provide {{{variables.phoneNo}}} as mobile number and select {{{}}} as school

Screenshot 2023-05-12 at 2.19.14 PM

Please console.log(school) before resolving. Check it in logs if its holding the value…

let {apiResponse} = ymLib.args;
apiResponse = JSON.parse(apiResponse); // if required.
let {school} = apiResponse;
console.log(school, "school in myfunction");

I see the API response is different now when youre checking through test. Isnt it!

yes, this changed after resolving only school

can you please give me the bot access

1 Like

gave you the access for bot