EDIT: Solved, posted details below as answer... Pretty stupid user error
I'm trying to write simple plugin for SteelSeries Gamesense to display currently playing song from iTunes in GameDAC screen. Basically the engine works via provided server listening to post requests with JSON body. I've been trying to get my request working for quite a while but with no go.
I tested request on Postman and it should be working as intended, so the problem is somewhere in syntax probably.
const axios = require('axios');
const coreProps = require(process.env.ProgramData + '/SteelSeries/SteelSeries Engine 3/coreProps.json');
const url = JSON.stringify(coreProps['address']);
axios.defaults.baseURL = 'http://' + url.replace(/"/g,'');
axios.defaults.headers['post'] = {'Content-Type': 'application/json'};
console.log(axios.defaults.headers);
function bind_itunes() {
const data = {
"game": "ITUNES",
"event": "NOWPLAYING",
"handlers": [
{
"device-type": "screened",
"zone": "one",
"mode": "screen",
"datas": [
{
"has-text": true,
"context-frame-key": "songname"
}
]
}
]
};
axios.post('game_event', JSON.stringify(data))
.then((res) => {
console.log(res)
}).catch((error) => {
console.error(error)
})
}
bind_itunes();
Code fails with long error block from Axios with error
"data: { error: 'passed value not string or JSON object' } }"
full error log (pastebin since it's quite long): https://pastebin.com/aLguKQ2C
Postman screenshot

JSON.stringify()on a URL? Can you share some screenshots of it working in Postman?axios.post('game_event', data)bind_game_eventbut your code is posting togame_eventso they're definitely not the same