This PR adds a new function to the extension/script.js file that allows the extension to interact with the /bookmarks endpoint. The function sends a GET request to the endpoint and handles the returned JSON data to add or remove bookmarks as needed.
Summary of Changes
Added a new function named fetchBookmarks to the extension/script.js file.
The fetchBookmarks function sends a GET request to the /bookmarks endpoint using the fetch function.
The endpoint URL is constructed using the endpoint variable and the string '/bookmarks'.
The function handles the returned response by parsing it as JSON and iterating over the data.
For each item in the data, the function checks if a bookmark with the same URL already exists.
If the bookmark does not exist, a new bookmark is added with the URL and title from the item.
If the bookmark exists and the title is different, the title of the bookmark is updated.
If the item has a property indicating that the bookmark should be removed, the bookmark is removed.
The fetchBookmarks function is called after the user has successfully logged in, in the then block of the fetch call in the auth function.
Please review and merge this PR to enable the extension to sync bookmarks with the server.
Fixes #15.
To checkout this PR branch, run the following command in your terminal:
git checkout sweep/add-bookmarks-function
🎉 Latest improvements to Sweep:
Use Sweep Map to break large issues into smaller sub-issues, perfect for large tasks like "Sweep (map): migrate from React class components to function components"
Getting Sweep to format before committing! Check out Sweep Sandbox Configs to set it up.
We released a demo of our chunker, where you can find the corresponding blog and code.
💡 To get Sweep to edit this pull request, you can:
Leave a comment below to get Sweep to edit the entire PR
Leave a comment in the code will only modify the file
Edit the original issue to get Sweep to recreate the PR from scratch
Description
This PR adds a new function to the
extension/script.js
file that allows the extension to interact with the/bookmarks
endpoint. The function sends a GET request to the endpoint and handles the returned JSON data to add or remove bookmarks as needed.Summary of Changes
fetchBookmarks
to theextension/script.js
file.fetchBookmarks
function sends a GET request to the/bookmarks
endpoint using thefetch
function.endpoint
variable and the string '/bookmarks'.fetchBookmarks
function is called after the user has successfully logged in, in thethen
block of thefetch
call in theauth
function.Please review and merge this PR to enable the extension to sync bookmarks with the server.
Fixes #15.
To checkout this PR branch, run the following command in your terminal:
🎉 Latest improvements to Sweep:
💡 To get Sweep to edit this pull request, you can: