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

198
Visualizações
synchronous function returning Promise { <pending> } instead of a value in typeORM transaction

I am using Typeform to store value multiple tables in my DB. But after saving my value it's the return Promise { } instead of a value. This is my function. I follow the most similar question link in StackOverflow to understand my problem. But non of that methods is not working for me...I really need your help. Thank you very much.

 async create(orderData: CreateOrderDto): Promise<any> {
    const orderModel: {
      created_date: Date;
      status: string;
      customer: Customer;
    } = {
      status: orderData.status,
      created_date: orderData.created_date,
      customer: orderData.customer,
    };

    try {
      await this.entityManager.transaction(
        async (entityManager: EntityManager) => {
          const order = await entityManager
            .getRepository(Order)
            .save(orderModel);
          if (order) {
            orderData.order_details.map(async (item) => {
              await entityManager
                .getRepository(OrderHasItem)
                .save({
                  order_id: order.id,
                  item_id: item.item_id,
                  unit_price: item.unit_price,
                  qty: item.qty,
                })
                .then((item) => {
                  console.log('item', item);
                  return item;
                });
            });
          }
        },
      );
    } catch (error) {
      console.log(error);
      throw new BadRequestException('There is an error');
    }
  }
about 4 years ago · Juan Pablo Isaza
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