calendar strip - move api call to proxy route
This commit is contained in:
parent
fde6a9cc83
commit
5773c1ef49
5 changed files with 116 additions and 20 deletions
|
|
@ -14,19 +14,6 @@ function getDatesInMonth(month) {
|
|||
}
|
||||
|
||||
async function getMapadoDates(monthNumb) {
|
||||
const myHeaders = new Headers();
|
||||
|
||||
const mapadoToken =
|
||||
"9bc321f5f47cf366c1c69eab4db69fe2a46819c75018237570473e2c961e210e227cc1e8cd8da7ba";
|
||||
|
||||
myHeaders.append("Authorization", "Bearer " + mapadoToken);
|
||||
|
||||
const requestOptions = {
|
||||
method: "GET",
|
||||
headers: myHeaders,
|
||||
redirect: "follow",
|
||||
};
|
||||
|
||||
const contractId = "1941";
|
||||
|
||||
const firstDayOfMonth = dayjs()
|
||||
|
|
@ -37,10 +24,44 @@ async function getMapadoDates(monthNumb) {
|
|||
.add(1, "month")
|
||||
.format("YYYY-MM-DD");
|
||||
|
||||
const url = `https://ticketing.mapado.net/v1/event_dates?itemsPerPage=100&contract=${contractId}&after=${firstDayOfMonth}&before=${firstDayOfNextMonth}&order=asc&fields=startDate,bookableStock,ticketing{@id,title,venue{@id,name,seatingName,address,zipCode,city,countryCode,timezone}}`;
|
||||
const requestEndPoint = 'event_dates'
|
||||
const requestParams = [
|
||||
{ name: 'itemsPerPage', value: 100 },
|
||||
{ name: 'contract', value: contractId },
|
||||
{ name: 'after', value: firstDayOfMonth },
|
||||
{ name: 'before', value: firstDayOfNextMonth },
|
||||
{ name: 'order', value: 'asc' }
|
||||
]
|
||||
|
||||
const requestFields = [
|
||||
{ name: 'startDate', },
|
||||
{ name: 'bookableStock', },
|
||||
{ name: 'ticketing', subfields: [
|
||||
{ name: "@id", },
|
||||
{ name: "title", },
|
||||
{ name: "venue", subfields: [
|
||||
{ name: "@id" },
|
||||
{ name: "address" },
|
||||
{ name: "zipCode" },
|
||||
{ name: "city" },
|
||||
{ name: "countryCode" },
|
||||
{ name: "timezone" },
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
];
|
||||
|
||||
const requestOptions = {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({requestEndPoint, requestParams, requestFields})
|
||||
}
|
||||
|
||||
const response = await fetch(url, requestOptions);
|
||||
const response = await fetch('/mapado.json', requestOptions);
|
||||
console.log(response)
|
||||
const json = await response.json();
|
||||
console.log(json)
|
||||
|
||||
const eventDates = json["hydra:member"];
|
||||
|
||||
console.log(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue