0

I want to make a check-conditionif()-case if the Buffer Array is filled, then continue, if not do something else. But Javascript has got me on its finest.

If I try to log the whole object with the BufferArray containing, it logs:

{"type":"Buffer","data":[137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,1,94,0,0,1,94,8,2,0,0,0,66,73,224,77,0,0,80...]

When I now try to log only the buffer array like so:

logger.info('Data is: ' + JSON.stringify(someObj.data))

The result is:

Data is: undefined

What are we doing wrong here? And how can i If-check if a buffer-array is empty or has data?

2
  • check if the somObj.data is undefined or null before apply stringify. if(someObj.data) console.log(JSON.stringify(someObj.data)) Commented Nov 11, 2019 at 14:43
  • We did this and if the array is filled it still does not log the buffer array. Commented Nov 11, 2019 at 14:47

1 Answer 1

1

The solution was to type:

JSON.parse(someObj.data)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.