Get the first and last days of the current month
Gets the first and last days of the current month and passes it to the request using
start_date
and
end_date
variables. The following script should be located in
Pre-request Script
let date = new Date();
let year = date.getFullYear()
let month = ("0" + (date.getMonth() + 1)).slice(-2)
let start_date = year+'-'+month+'-01';
let days = new Date(year, month, 0).getDate()
let end_date = year+'-'+month+'-'+days;

pm.collectionVariables.set("start_date", start_date);
pm.collectionVariables.set("end_date", end_date);
Get URL of the request
https://httpbin.org/get?start_date={{start_date}}&end_date={{end_date}}
by Valeri Tandilashvili
2 years ago
Postman
0
Pro tip: use ```triple backticks around text``` to write in code fences