Dividing Minutes by 5?

I’m new to constructing headers and a vendor I’m working with is requiring that a header value.

They provided a custom password and I’m required to add the UTC Date and hour and then the UTC minute divided by 5. All this is in a SHA256 string to hash.

I started with adding apikey to headers with {{apikey}} and then moved to pre-request script

started putting together some const password = "password’ and time / minute, but I have not seen a command to divide?

Anyone ever work with this?

The final result should be

apikey = sha256 hash ( PASSWORD-YYYY-MM-DD-HH-MM/5)

Thanks in advance.

Hi @docking-module-engi3

You won’t be able to divide the date by 5, but you could divide the ‘minute’ by 5.

Here is some example code that shows dividing the data results in NaN (not a number)… but also shows how to divide just the minute.

const moment= require('moment');
let today = moment().format("yyyy-MM-DD-HH-mm");
let divDate = today / 5;

let minute = moment().format("mm");
let divMinute = minute / 5;

If this doesn’t help could you be a little more specific and possibly share the API documentation for what you are trying to do?

1 Like

Thanks so much. I was able to do something similar, but did not think of putting in the second row of let divMinute

I used something like this:
let minute = moment().format(“mm”) / 5;

Appears it produces the same results. Thanks again!

1 Like

Looks fine to me, I wrote the other way as it’s just a little easier to interpret for people that don’t work with code regularly. But both ways will work.

Glad it’s working :upside_down_face: