Js script to retrieve API token

Hi All,
I am naïve to use Orchestrator API.
i am working on the POC where my custom form interface can retrieve transaction items from an Orchestrator queue in JSON format.
Inorder to connect with the API we have taken help from the link

and coded it in js which is below:

// request parameters specific to cloud Orchestrator instance
var url = ‘https://platform.uipath.com/coxinc/coxTestgokb300096’;
var userKey = ‘pBEdXhETED2_yIRJ_RWrNob3orzNa7YWz6Q5zqVFkMr3K’;
var clientId = ‘8DEv1AMNXczW3y4U15LL3jYf62jK93n5’;

// this is the body format of the initial authentication request
var requestBody = {
“grant_type”: “refresh_token”,
“client_id”: clientId,
“refresh_token”: userKey

// define a var to hold the result of the AJAX call
var resp
var token

// build out the rest of the auth request
var settings = {
“url”: “https://account.uipath.com/oauth/token”,
“method”: “POST”,
“timeout”: 0,
“headers”: {
“Content-Type”: “application/json”,
“data”: JSON.stringify(requestBody)

//exec the ajax and write to dom
$.ajax(settings).done(function (response) {
resp = response;
token = resp.access_token;

Now i want to retrieve the dataItems from the Transaction queue present in Orchestrator:
Can anyone please support me how i can get the list of queues and match the name to the ID
GET Queues - Get All
Then to retrieve all items in the queue based on the queue ID
GET Queues Items- Get all by queue id

And then how can i inject this js into uipath and retrieve the queue item in json format for further processing.