php – how to microtime in NodeJS-ThrowExceptions

Exception or error:

How to retrieve microtime in NodeJS?
I want to use it to create unique transaction_id everytime user hit my API.
I have tried to follow suggestion from this thread: How to get a microtime in Node.js? but no luck.

When I hit API (using postman), the value is as same as I hit API twice. It didn’t change. So it is not a unique value then.

I used to create it on PHP, using trx_id = microtime(); so everytime user hit my API, those “trx_id” value is always change. But it didn’t work in NodeJS. Anyone knows why?
Appreciate your help.

PS: Other suggestion are welcome. The point is, I need to create unique trx_ID everytime user hit my API. My idea is use microtime() just like I did on PHP before.

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *