-
Notifications
You must be signed in to change notification settings - Fork 1
Bulk delete recent Pocket items
Peter deHaan edited this page Apr 29, 2015
·
3 revisions
The following snippet permanently deletes your last 10 items from your Pocket list using Pocket#get()
and Pocket#send()
:
var Pocket = require('pocket-promise')
var config = require('./config.json')
var pocket = new Pocket(config)
// Delete the 10 last items from your list.
pocket.get({
count: 10
}).then(function (items) {
var list = Object.keys(items.list)
var actions = list.map(function (item_id) {
return {
action: 'delete',
item_id: item_id
}
})
if (actions.length) {
pocket.send({
actions: actions
}).then(pretty).catch(pretty)
}
})
function pretty (data) {
console.log(JSON.stringify(data, null, 2))
}
{
"action_results": [
true,
true,
true,
true,
true,
true
],
"status": 1
}
NOTE: If you only want to delete a single item (by item_id
), you can use the Pocket#delete()
API:
pocket.delete({
item_id: 20646
}).then(console.log).catch(console.error)
... which is just a pretty shorthand for:
pocket.send({
actions: [
{
action: 'delete',
item_id: '20646'
}
]
})