Skip to content

Instantly share code, notes, and snippets.

@mikekreeki
Created August 27, 2025 13:16
Show Gist options
  • Save mikekreeki/3a551477656dc8477812f1ac753aba7e to your computer and use it in GitHub Desktop.
Save mikekreeki/3a551477656dc8477812f1ac753aba7e to your computer and use it in GitHub Desktop.
javascript: ((areaId, token) => {
var options = {
method: 'POST',
headers: {
Authorization: 'Bearer ' + token,
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
task: {
area_id: areaId,
name: document.title,
note: '<' + window.location.href + '>',
}
})
};
var onSuccess = (response) => {
if (response.status !== 201) {
response.json().then((data) => {
window.alert('Error saving web page to Lunatask: ' + JSON.stringify(data));
})
} else {
window.alert('Saved to Lunatask!');
}
};
var onError = (error) => {
window.alert('Error saving web page to Lunatask: ' + error.message);
};
fetch('https://api.lunatask.app/v1/tasks', options).then(onSuccess).catch(onError);
})('insert-area-id-here', 'insert-api-token-here');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment