Generate random 10-digit number

I would like to create a dynamic variable - a random 10-digit number
how do i do this?

Hi,

A simple way to do it, is to use the built-in library lodash.

e.g.
const randomNumber = _.random(1000000000,9999999999)

If you need to use it in a request, you can add this to a pre-request script like this:

const randomNumber = _.random(1000000000,9999999999)
pm.variables.set(‘randomNumber’, randomNumber )

then in the request body, add {{randomNumber}}

e.g.

{
    "username": "Test",
    " number": "{{randomNumber}}"
}

I hope this helps.

2 Likes

amazing
thank you very much!!