In this blog post, we will create a function to copy a folder or directory in AWS S3. We need to do a bit of extra work to copy objects because folders don't exist in S3 - even if it seems like they do!
You can access response headers in axios from the response per request, or by adding an interceptor to all requests. If the headers are missing or undefined, you might need to fix your CORS settings.
If your MongoDB data doesn't match up with the response object you need to provide, you can use `.project()` to change a field name and respond with a different field name instead!
If you have an HTML string, and you need to find all the HTML tags with regex, here's the Regular Expression code you can use to do it.
If you need to get HTML attributes, to check them or replace them, regex could hold the answers! Here's the Regular Expression I use, and a step-by-step guide for how I built it.
You can invalidate an active query to get it to force refetch with React Query. Here's how you can force refetch after a mutation, or on a button click, to check for updated data.
Here's something that caught me out this week - skip and limit order in MongoDB. The order of skip and limit isn't important in chaining (like `find` commands) but it is important in aggregation.
In React Query, the cacheTime and staleTime options impact how long data gets stored on the client and how often it's re-fetched from the server. Let's look at the difference between cacheTime and staleTime - and how changes to one can impact the other.
If browsers save old code bundles for your React app, it can create errors and problems loading your app for your users. Here are some cache-busting tips for React in production.
This is how I store paginated queries when I also want users to know the total results count and total number of pages for paginated data.
Drag and drop can be a little tricky to implement. Here are some common problems you might run into and how to fix them to get your drag-and-drop working like a charm.
One of my favourite features of Trello is how you can drag and drop your cards around, so here's how I created a Trello-like drag-and-drop kanban board from scratch in React.
Drag and drop is a pretty cool feature to add to your web applications. But it can be a little tricky. With some trial and error, here's how I built a reusable drag-and-drop component for React (and all the code!).
As I use a cloud IDE, sometimes the only copy of my code is in a GitHub repo. And that got me worried. Here's how I create a backup on Bitbucket.
I’m really interested to know how people take on a big full-stack project. Do you start with the front end (client) or the back end (server)? So I’ll share my approach - which is one small feature at a time - and why it works for me.
Both throttling and debouncing are useful ways to slow down how often a function runs when it's called multiple times. Throttling allows a function to be called once during a timeframe, and debouncing calls a function once after the timeframe.
In this blog post, we will create a `toPlural` function that does slightly more than just add an "s" to the end of a word if the number is more than one!
Here's how to scroll to an element after you render a component in React with `useRef` and `useEffect`. And if you need to do it more than once, I've included a custom `useScrollOnRender` hook you can use.
There's more than one way to update a document in MongoDB. Here's when (and why) I use `findOneAndUpdate` instead of `updateOne` to update a document with MongoDB in Node.js.
When you use the `upsert` option with `findOneAndUpdate` in MongoDB, it's not easy to know if the document was inserted or updated. Here's how I check if a document was created when returning the document before, or after the update.