⬇️ Fetched qBittorrent settings

This commit is contained in:
2023-10-23 14:07:52 -04:00
parent 4ea9086e3f
commit 2df0fce792
3 changed files with 34 additions and 28 deletions

View File

@@ -4,20 +4,26 @@ export const torrentsApi = emptySplitApi.injectEndpoints({
endpoints: (builder) => ({
connectToQBittorrentClient: builder.query({
queryFn: async (_arg, _queryApi, _extraOptions, fetchWithBQ) => {
const qBittorrentHostInfo = await fetchWithBQ(
"localhost:3000/api/settings/getAllSettings",
);
await fetchWithBQ({
url: "localhost:3060/api/qbittorrent/connect",
method: "POST",
data: qBittorrentHostInfo,
});
console.log(qBittorrentHostInfo);
return {
url: "",
method: "GET",
data: qBittorrentHostInfo,
};
try {
const {
data: { bittorrent },
} = await fetchWithBQ("localhost:3000/api/settings/getAllSettings");
await fetchWithBQ({
url: "localhost:3060/api/qbittorrent/connect",
method: "POST",
body: bittorrent?.client?.host,
});
const { data } = await fetchWithBQ({
url: "localhost:3060/api/qbittorrent/getClientInfo",
method: "GET",
});
return {
data: { bittorrent, qbittorrentClientInfo: data },
};
} catch (err) {
throw err;
}
},
}),
}),