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)
|
||||
).then(result =>
|
||||
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
|
||||
filename = `${date}/${f.name}`
|
||||
const url = f.fileUrl
|
||||
|
@ -93,7 +93,7 @@ async function mergeEventSongs(event) {
|
|||
await merger.save(merged);
|
||||
const mergedPdfBuffer = await merger.saveAsBuffer();
|
||||
var data = new FormData();
|
||||
data.append("files", [mergedPdfBuffer])
|
||||
data.append("files[]", mergedPdfBuffer)
|
||||
resolve(await churchtoolsClient.post(`/files/service/${event.id}`, data))
|
||||
})
|
||||
})
|
||||
|
@ -105,9 +105,10 @@ login().then(() => {
|
|||
console.log(`Hello ${whoAmI.firstName}!`);
|
||||
});
|
||||
return churchtoolsClient.get('/events')
|
||||
}).then(events => {
|
||||
const event = events[3];
|
||||
return mergeEventSongs(event);
|
||||
/*}).then(events => {
|
||||
// TODO uncomment this block and select desired event id here
|
||||
const event = events[1];
|
||||
return mergeEventSongs(event); */
|
||||
}).then(result => {
|
||||
console.log(result)
|
||||
}).catch(error => {
|
||||
|
|
Loading…
Add table
Reference in a new issue