'RabbitMQ payload to Array

Has anyone worked with RabbitMQ? I have already implemented the implementation here, it is already reading the queue, what is needed is to take the payload, which in this case is not in JSON format, and convert it into an array, to get each position and insert this part into a MySQL table, from MySQL, it is also ok, but to test, I failed the data, I just need to get the correct positions of this JSON, and put them in their proper places to enter the right data in the database.

queue.activateConsumer(
    function (message) {
      const content = message.getContent();
      const seconds = content.split('.').length - 1;
      console.log(` [x] received message: ${content}`);
      setTimeout(async function () {
        const bd = await prisma.property.create({
          data: {
            user_id: 560,
            client_id: 350,
            owner_id: 450,
            name: 'Teste name',
          },
        });
        console.log(' [x] Done');
        message.ack();
      }, seconds * 1000);
    },
    { noAck: false },
  );

The function is this one, I need to get this constant "content" and transform it into an array, or use something like a split, this I can't do, can anyone help?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source