- Send an HTTP request using the POST method to the localhost:3000/randnum endpoint.
- Set the
upperdata parameter value. This will be used to generate random integers from1toupper. - Receive the random number.
Although the upper parameter is the only required part of the request, there are other optional parameters that could be useful.
upper- the largest generated value.lower(optional) - this is1by default and it represents the lowest generated value.min_limit(optional) - the minimum accepted value.1by default.max_limit(optional) - the maximum accepted value.1000by default.
The generated random number will be sent with a 200 OK response as the value of the number key in a JSON object. See the example below.
Note
Examples of requests are formatted for readability. The original URL is provided.
Formatted request:
{
upper: '6'
}Response:
{
"number": 4
}Formatted request:
{
lower: '0',
upper: '6'
}Response:
{
"error": "Out of range - the 'lower' and|or 'upper' values must be in the closed range [1 - 1000]."
}Important
If you wish to use 0 as a value of lower, then you must modify the min_limit to be less than or equal to your desired lower limit.
Formatted request:
{
"lower":"10",
"upper":"16",
"min limit":"10",
"max limit":"20"
}Response:
{
"number": 12
}