Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

179
Visualizações
Cannot read properties of undefined (reading '0') jquery

i have map in array but in error Cannot read properties of undefined (reading '0') thanks guide me

axios({
    method: "get",
    url: `${baseURL}/ShowProduct`,
  })
  .then(res => {

      loading = false;
      loadingg();
      if ((res.data.message) != "ProductNotFound") {


        // arrayrespons = res.data.message;

        res.data.message.map((item, index) => {


              listItems.push(item.id + "-" + item.ProductName)
              listIds.push(item.id);
              arrayrespons.push(item)

              let optionSelUnit = ``;

              if (item.unit != "" && item.unit[0].name != null) {
                // alert("ffg")
                unit = item.unit[0].parent.name;
                item.unit.map(itm => {
                  optionSelUnit += `<option>${item.name}</option>`
                })
              } else if (item.unit != "" && item.unit[0].name == null) {
                unit = item.unit[0].parent.name;
              } else if (item.unit == "") {
                unit = '-'
              }
              if (item.MasterChef == 1) {
                MasterChef = "checked"
              } else {
                MasterChef = ""
              }
              if (item.Active == 1) {
                Active = "فعال"
              } else {
                Active = "غیرفعال"
              }
              if (item.Description == null) {
                DescriptionShow = "توضیحاتی ثبت نشده است "
              } else {
                DescriptionShow =
                  item.Description
              }
              DescriptionShow = moreCharacter(DescriptionShow);
              if (item.Description == null) {
                descShowProduct = ""
              } else {
                descShowProduct = item.Description
              }

              if ((item.DiscountId) != null) {
                Discount = item.Dis_price;
                MoneyUnit = item.MoneyUnit;
              } else if (item.festival_id != null) {
                Discount = item.festival_price;
                MoneyUnit = item.MoneyUnit;
              } else {
                Discount = "تخفیف ندارد"
                MoneyUnit = ""
              }
              if (item.Weight == null) {
                Weight = "-"
              } else {
                Weight = item.Weight
              }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

When you use Map function you must return new object inside map arrow function.

Simple example:

menuList.map(menu => {
   return {
        MenuId: menu.id
        MenuName: menu.name
   }
})

This part maps each item in menulist to new object You didn't return mapped object and just insert it to other object

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda