-
-
Save ww9rivers/dc3fd9ba8d2817b9fc986aa9457a2b61 to your computer and use it in GitHub Desktop.
A JS version of the rest1.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import diagnostics_channel from 'node:diagnostics_channel'; | |
import querystring from 'node:querystring'; | |
const SEARCH_ENDPOINT = `https://${process.env.SPLUNK_HOST}:8089/services/search/jobs`; | |
const data = { | |
search: "inputcsv pharmacy-calls.csv", | |
output_mode: "json" | |
}; | |
const options = { | |
method: "POST", | |
mode: "cors", | |
cache: "no-cache", | |
credentials: "same-origin", | |
headers: { | |
Authorization: `Bearer ${process.env.SPLUNK_TOKEN}`, | |
Accept: "application/json" | |
}, | |
redirect: "follow", | |
referrerPolicy: "no-referrer", | |
body: querystring.encode(data), | |
}; | |
diagnostics_channel.subscribe('http', (message, name) => { | |
console.log('name:', name); | |
console.log('message:', message); | |
}) | |
let response = await fetch(SEARCH_ENDPOINT, options); | |
console.log(response.status); | |
console.log(response.body); | |
console.log(await response.json()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See the Python3 version of this script for details.