Can anyone help me how to do this in javascript if it's possible?
curl \
-H 'Accept: application/json' \
-H 'Client-ID: <client_id>' \
-d'{"channel_id":<channel_id>}' \
-X POST 'https://open-api.trovo.live/openplatform/channels/id'
Can anyone help me how to do this in javascript if it's possible?
curl \
-H 'Accept: application/json' \
-H 'Client-ID: <client_id>' \
-d'{"channel_id":<channel_id>}' \
-X POST 'https://open-api.trovo.live/openplatform/channels/id'
You can either use a child_process
or convert to a fetch(or equivalent)
const exec = require('child_process').exec;
exec('curl ...', function (error, stdout, stderr) {
// handle result
})
Why you want to use JS.
You can use JQUERY Ajax:
$.ajax({
url: url,
dataType: "json",
type: "POST/GET",
async: true,
data: { },
success: function (data) {
//code
},
error: function (xhr, exception) {
//console.log err
}
});
This is JS Fetch API:
fetch("https://open-api.trovo.live/openplatform/channels/id", {
headers: {
Accept: "application/json",
"Client-Id": "<client_id>"
},
method: "POST"
})