37 lines
1023 B
JavaScript
37 lines
1023 B
JavaScript
import fetch from 'node-fetch';
|
|
import { BASE_URL, BASE_HEADERS, BASE_PARAMS } from '../util/Constants';
|
|
|
|
const cookie = {
|
|
JSESSIONID: "ffu-WeUdcd3ICqoCimutvnpdERv3XONZ-VMxwg4-.eteenindusw-n1",
|
|
mntClientId: "15QY8LHHIST1C",
|
|
ROUTEID: ".et1",
|
|
plumbr_user_tracker: "a71e97ae-1d54-5fce-a758-cbf37e01c093",
|
|
plumbr_session_tracker_bkae1x: "004aec88-b58e-036b-2c05-ee309bfaa88b|1590327356024"
|
|
};
|
|
|
|
const formatCookie = 'JSESSIONID=OWbYYl4zGt6GOBW8nHFf9jX836540u0Bi-y5T6hf.eteenindusw-n1; mntClientId=15QY8LHHIST1C; ROUTEID=.et1; eteenindus_lang=en';
|
|
|
|
class Api {
|
|
constructor() {}
|
|
|
|
/**
|
|
* @param {string} plate @TODO implement usage
|
|
*/
|
|
async fetch(plate = "") {
|
|
try {
|
|
console.log(`Fetching data for ${plate}`);
|
|
return (await fetch(BASE_URL, {
|
|
"headers": {
|
|
...BASE_HEADERS,
|
|
"Cookie": formatCookie
|
|
},
|
|
...BASE_PARAMS,
|
|
})).text();
|
|
} catch (e) {
|
|
throw Error(`Failed to fetch data, reason: ${e.message}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
export default Api;
|