diff --git a/__tests__/qbittorrent/auth.test.ts b/__tests__/qbittorrent/auth.test.ts index 9cc5ec8..5aa21d6 100644 --- a/__tests__/qbittorrent/auth.test.ts +++ b/__tests__/qbittorrent/auth.test.ts @@ -12,9 +12,9 @@ test('loginV2', async t => { password: 'adminadmin' } - const scope = nock(fakeSettings.url).post('/api/v2/auth/login', (b) => { - console.log(b); - return true; + const scope = nock(fakeSettings.url).post('/api/v2/auth/login', { + username: 'admin', + password: 'adminadmin' }).reply(200, {}, { 'set-cookie': 'SID=1234' }); diff --git a/build/src/qbittorrent/api.js b/build/src/qbittorrent/api.js index e65794c..82699d1 100644 --- a/build/src/qbittorrent/api.js +++ b/build/src/qbittorrent/api.js @@ -129,6 +129,13 @@ export const login = (qbittorrentSettings) => { const form = new FormData(); form.append('username', qbittorrentSettings.username); form.append('password', qbittorrentSettings.password); - return axios.post(`${qbittorrentSettings.url}${ApiEndpoints.login}`, form); + return axios.post(`${qbittorrentSettings.url}${ApiEndpoints.login}`, { + username: qbittorrentSettings.username, + password: qbittorrentSettings.password + }, { + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + } + }); }; //# sourceMappingURL=api.js.map \ No newline at end of file diff --git a/src/qbittorrent/api.ts b/src/qbittorrent/api.ts index 2a773af..4a21417 100644 --- a/src/qbittorrent/api.ts +++ b/src/qbittorrent/api.ts @@ -158,10 +158,14 @@ enum ApiEndpoints { } export const login = (qbittorrentSettings: QBITTORRENT_SETTINGS): Promise => { - const form = new FormData(); - form.append('username', qbittorrentSettings.username); - form.append('password', qbittorrentSettings.password); - return axios.post(`${qbittorrentSettings.url}${ApiEndpoints.login}`, form); + return axios.post(`${qbittorrentSettings.url}${ApiEndpoints.login}`, { + username: qbittorrentSettings.username, + password: qbittorrentSettings.password + }, { + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + } + }); } // We just need the hash for some of the API calls