Urgent: cannot get token, api seems to be down

Hi there
API login seems to be down

import { pipe } from "gamla";

const fetchJson = <T>(...x: Parameters<typeof fetch>) =>
  pipe(fetch, async (x: Response) => {
    if (x.status === 200) return x.json();
    throw new Error(
      `failed fetching ${x.status} ${x.statusText} ${await x.text()}`,
    );
  })(...x) as Promise<T>;

const getToken = (username: string, password: string) =>
  fetchJson<{ token: string }>("https://api.opensubtitles.com/api/v1/login", {
    method: "POST",
    headers: new Headers({
      Accept: "application/json",
      "Api-Key": apiKey,
      "Content-Type": "application/json",
      "User-Agent": userAgent,
    }),
    body: JSON.stringify({ username, password }),
  }).then(({ token }) => token);

returns an html page which starts with <title>api.opensubtitles.com | 502: Bad gateway</title>

1 Like

Yes this was a server error, nothing do do with the language used

it’s solved now