Fix linting errors

This commit is contained in:
Jason Fischer 2022-09-12 20:06:00 -07:00
parent 95b6ea0e23
commit b19b4f047e
2 changed files with 16 additions and 15 deletions

View file

@ -1,6 +1,5 @@
import { httpProxy } from "utils/http";
import { formatApiCall } from "utils/api-helpers";
import getServiceWidget from "utils/service-helpers";
export default async function transmissionProxyHandler(req, res) {
@ -20,6 +19,7 @@ export default async function transmissionProxyHandler(req, res) {
const csrfHeaderName = "x-transmission-session-id";
const method = "POST";
const auth = `${widget.username}:${widget.password}`;
const body = JSON.stringify({
method: "torrent-get",
arguments: {
@ -27,27 +27,27 @@ export default async function transmissionProxyHandler(req, res) {
}
});
const reqHeaders = {
const headers = {
"content-type": "application/json",
};
let [status, contentType, data, responseHeaders] = await httpProxy(url, {
method: method,
auth: `${widget.username}:${widget.password}`,
body: body,
headers: reqHeaders,
method,
auth,
body,
headers,
});
if (status === 409) {
// Transmission is rejecting the request, but returning a CSRF token
reqHeaders[csrfHeaderName] = responseHeaders[csrfHeaderName];
headers[csrfHeaderName] = responseHeaders[csrfHeaderName];
// retry the request, now with the CSRF token
[status, contentType, data] = await httpProxy(url, {
method: method,
auth: `${widget.username}:${widget.password}`,
body: body,
headers: reqHeaders,
[status, contentType, data, responseHeaders] = await httpProxy(url, {
method,
auth,
body,
headers,
});
}