Hello,
I just started my journey with Javascript and also with K6.
Is there anyone here that would like to me to write a code that would generate an authorization ‘Bearer token’?
Below is a photo of an example my token generator in postman.
Here is my current code, but it is not effective, as I have to copy and paste the token from postman generator to my K6 script:
export default function(){
let params = {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJ2dTFmbFlpZkNpSzEwUEJyU0tUZzU5TXR4TUJvMC1KZXR4........`,
},
};
let res = http.get('https://api.example.com/customers/11177/account/balance', params);
check(res, {
'status of account balance was 200': (r) => r.status == 200,
});
sleep(1);
};