Created
January 21, 2023 04:15
-
-
Save djyde/32fd10fe32a71e49a44737f6515e605a to your computer and use it in GitHub Desktop.
Readwise scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function getBooks(category) { | |
return await (await fetch(`/api/books/?category=${category}`)).json() | |
} | |
async function deleteBook(id) { | |
return await (await fetch(`/api/user_delete_book`, { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', | |
'X-CSRFToken': Cookies.get('csrftoken') | |
}, | |
body: new URLSearchParams({ | |
userBookId: id, | |
isPermanent: 'true' | |
}) | |
})).json() | |
} | |
async function run() { | |
const books = await getBooks('tweets') | |
for (const book of books) { | |
console.log('deleteing', book.id) | |
await deleteBook(book.id) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment