2

I use iota/Cliente, to submit a message with some data from a json file. Now i try to get this data using getMessage() with the messageId or Index.

I try this:

const client = new ClientBuilder().build();

const message = await client.getMessage().data("ddd5a550d5df1094e7badddd8a857f64d15a708f1972c81d7a88fbcc8f9b2170")
console.log(message);

But only get information from the message, childs, network etc but no data. Any idea?

2

The data is inside of the indexation payload, you can get it like this

    const message = await client.getMessage().data("ddd5a550d5df1094e7badddd8a857f64d15a708f1972c81d7a88fbcc8f9b2170")
    const decoded = new TextDecoder().decode(new Uint8Array(message.message.payload.data.data));
    console.log(JSON.stringify(JSON.parse(decoded), null, 1));
1
  • Thanks men, it work well when i use it in a simple node project. But when i try it in a node API Express project (I'm working now) i have a json error: SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>) It's the same, any idea?
    – JuanHost
    May 18 at 2:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.