How to send a simple javascript request to Web UI
Posted: Tue Oct 26, 2021 3:39 pm
I'm failing to send a basic axios request to qbittorrent, even though it works perfectly fine when I send the very same request in an api manager like postman. The my web UI runs on port 5050, and I'm trying to send a post request to http://127.0.0.1:5050/api/v2/torrents/add, which should add a new torrent.
Here's the image of the insomnia request, which works:
And here's my javascript code, which doesn't:
Here's the image of the insomnia request, which works:
And here's my javascript code, which doesn't:
Code: Select all
const data = new FormData();
data.append(
'urls',
'https://yts.mx/torrent/download/0CE7772B55BEF2DA98C49AA1DF608DEBBB20670F'
);
data.append('savepath', 'G:/My Drive/downloads/');
data.append('category', 'Movies');
await axios.post(`http://127.0.0.1:5050/api/v2/torrents/add`, data, {
headers: data.getHeaders()
});