(antoher) extract item from array question

Hi there,
I read a few tutorials and thread here. I have done that in other make scenario. But can’t get this one workgin.
Here is the data structure (json) I simplified it.
[
{
“node”: {
“id”: “order_hbCzmpxLwNeJIQKCjWmdP”,

        "payments": [
            {
                "id": "pay_Wh13oi8Av6VExEvdd4b5-",
                "_id": 2247331,
                "total": 64.4,
                "source": {
                    "payment_gateway": {
                        "prototype": {
                            "key": "paypal"
                        }
                    }
                },
                "refunds": [],
                "refunded": 0,
                "sub_total": 64.4,
                "created_at": "a few seconds ago",
                "refundable": 64.4,
                "discount_snapshot": null,
                "price_bundle_snapshot": []
            }
        ],

I want to set a variable with the payments.source.payment_gateway.prototype.key
Here for example I should get the value “paypal”.
I used this formula in a set variable module

But the variable comes back empty.
Any Idear
Thanks

Welcome to the Make community!

I think you are confusing map with get.

  1. Change your get( to map(

  2. Then wrap it with first() or a get()

Links

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —

General

Help Center Basics

2 Likes

Thanks a lot samliew,
Indeed it was a bit mixt up. I ended up trying lots of things and the screen shot I sent was definitively not the best ;). I did some more testing after reading tutos. I am still not successfull.
Any help would be appreciated
Regards

I tried this :

It gave this result (empty)

And here is the structure of the array I am trying to work with What I want is the the value of the source.payment_gateway.prototype.key. In this case “paypal”

Hi @anton_pre

This is a bit tricky. Please use the ‘get an toArray’ function as shown below.
Input:


Output:

If you require additional assistance, please don’t hesitate to reach out to us.
MSquare Support
Visit us here
Youtube Channel

3 Likes

Thanks a lot.
It worked.
That made my day :grinning:

2 Likes

@anton_pre

Glad to help you!

If you require additional assistance, please don’t hesitate to reach out to us.
MSquare Support
Visit us here
Youtube Channel

2 Likes