I
I
ipatovd2018-10-10 12:11:12
JavaScript
ipatovd, 2018-10-10 12:11:12

How to access an API element?

There is a response from API:

_embedded: {
  items: [
      {
          id: 402582,
          name: "402582",
          custom_fields: [
              {
                  id: 350969,
                  name: "Артикул",
                  values: [
                      {
                          value: "775977"
                      }
                  ],
                  is_system: true
              },
              {
                  id: 355993,
                  name: "Код1с",
                  values: [
                      {
                          value: "ЦБ000002162"
                      }
                  ],
                  is_system: false
              },
          ],
      }
  ]
}

The array turns out to be large, I go through it FOR, but how can I get access to value in custom_fields by object id?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ihor Bratukh, 2018-10-10
@ipatovd

_embedded.items.forEach(function(item) {
  item.custom_fields.forEach(function(field) {
    console.log(field);
  });
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question