fix: async cookieJar
This commit is contained in:
parent
740dd892f9
commit
36923ee5aa
1 changed files with 6 additions and 5 deletions
11
index.js
11
index.js
|
@ -59,7 +59,7 @@ async function mergeEventSongs(event) {
|
||||||
Promise.allSettled(result)
|
Promise.allSettled(result)
|
||||||
).then(result =>
|
).then(result =>
|
||||||
result.map(song => song.value.files.find(f => f.name.includes("Akkorde")))
|
result.map(song => song.value.files.find(f => f.name.includes("Akkorde")))
|
||||||
.map(f => {
|
.map(async (f) => {
|
||||||
// https://github.com/churchtools/churchtools-js-client/issues/25
|
// https://github.com/churchtools/churchtools-js-client/issues/25
|
||||||
filename = `${date}/${f.name}`
|
filename = `${date}/${f.name}`
|
||||||
const url = f.fileUrl
|
const url = f.fileUrl
|
||||||
|
@ -93,7 +93,7 @@ async function mergeEventSongs(event) {
|
||||||
await merger.save(merged);
|
await merger.save(merged);
|
||||||
const mergedPdfBuffer = await merger.saveAsBuffer();
|
const mergedPdfBuffer = await merger.saveAsBuffer();
|
||||||
var data = new FormData();
|
var data = new FormData();
|
||||||
data.append("files", [mergedPdfBuffer])
|
data.append("files[]", mergedPdfBuffer)
|
||||||
resolve(await churchtoolsClient.post(`/files/service/${event.id}`, data))
|
resolve(await churchtoolsClient.post(`/files/service/${event.id}`, data))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -105,9 +105,10 @@ login().then(() => {
|
||||||
console.log(`Hello ${whoAmI.firstName}!`);
|
console.log(`Hello ${whoAmI.firstName}!`);
|
||||||
});
|
});
|
||||||
return churchtoolsClient.get('/events')
|
return churchtoolsClient.get('/events')
|
||||||
}).then(events => {
|
/*}).then(events => {
|
||||||
const event = events[3];
|
// TODO uncomment this block and select desired event id here
|
||||||
return mergeEventSongs(event);
|
const event = events[1];
|
||||||
|
return mergeEventSongs(event); */
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
console.log(result)
|
console.log(result)
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue