Hi everyone,
I’m struggling getting the responses of the API call I make. It’s been two days I’ve been on it and I cannot find a way to make it work properly… Here’s the use case.
- I need the user to choose between 5 products and to select the options he wants (between option A and B). The final amount will not be the same depending on product & options. It’s basically sums.
- I cannot change the body structure of the answer I get. Here’s what it looks like:
product1 {
“name”: productnameA
“statusCode”: x
“statusMessage”: x
“beans”: [
{
“code”: A
“label”: A
“amount”: 1
“amount2”: 1
},
{
“code”: optionA
“label”: A
“amount”: 1
“amount2”: 1
},
{
“code”: optionB
“label”: B
“amount”: 1
“amount2”: 1
},
],
product2 {
“name”: productnameB
“statusCode”: x
“statusMessage”: x
“beans”: [
{
“code”: priceA
“label”: A
“amount”: 1
“amount2”: 1
},
{
“code”: optionA
“label”: A
“amount”: 1
“amount2”: 1
},
{
“code”: optionB
“label”: B
“amount”: 1
“amount2”: 1
},
],
-> this is what I get from Postman’s body response
How can do that the simpler way?
I’ve thought of two different possibilities:
- The first one is making 20 calls (because in total there are 20 different possible prices), each call will have different variables. The thing is: how bad is it for the performance? Plus it’s not maintainable if more options or more products will be available in the future…
- The second one is to make only 1 call and to store temporary all the data (all the products, all the flat prices & the options), to make like custom states depending of the options the user choose front end and it will sum the amounts together.
For that, I’ve tried it both ways: ACTION and DATA.
—With Action, I tried to create a new Thing and to store all the data in it, but the thing is that all the products are stored in the same thing, instead of being in 5 (I have 5 products) -> Is there a way to parse it so it can be on 5 different records/things?
—With Data, I cannot know how to simply get in ONE call all the responses. It seems to be 1 call = 1 specefic response (like the price of 1 option)
Thank you very much
)