This commit is contained in:
Nikhil Nawgiri 2024-10-26 16:56:30 +02:00
parent 195484b42e
commit eb99cbe544
2 changed files with 30 additions and 31 deletions

View file

@ -0,0 +1,29 @@
import fetch from "node-fetch";
import { API_BASE, API_TOKEN } from "../config.ts";
const API_ENDPOINT_WITH_PARAMS = "/Items?isMovie=true&isSeries=true&recursive=true&fields=ProviderIds&filters=&mediaTypes=Video&enableTotalRecordCount=true&enableImages=false";
const API_URL = API_BASE + API_ENDPOINT_WITH_PARAMS;
export const fetchFromApi = async () => {
const init = {
method: "GET",
headers: {
accept: "application/json",
"Content-Type": "application/json",
Authorization: `MediaBrowser Token=${API_TOKEN}`,
},
};
const response = await fetch(API_URL, init)
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
console.log("response:", response);
}

View file

@ -1,33 +1,3 @@
import fetch from "node-fetch";
import { API_BASE, API_TOKEN } from "../config.ts";
const API_ENDPOINT_WITH_PARAMS = "/Items?isMovie=true&isSeries=true&recursive=true&fields=ProviderIds&filters=&mediaTypes=Video&enableTotalRecordCount=true&enableImages=false";
const API_URL = API_BASE + API_ENDPOINT_WITH_PARAMS;
const fetchFromApi = async () => {
const init = {
method: "GET",
headers: {
accept: "application/json",
"Content-Type": "application/json",
Authorization: `MediaBrowser Token=${API_TOKEN}`,
},
};
const response = await fetch(API_URL, init)
.then(response => {
if (!response.ok) {
console.log("response:", response);
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
})
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
console.log("response:", response);
console.log("API_URL:", API_URL);
console.log("init:", init);
}
import { fetchFromApi } from "./fetchItemsFromJellyfin.ts";
fetchFromApi();