6 hours later…
05:46
6 hours later…
12:13
@JMoss Of course. The code in your
click
listener is executed whenever you click on rock
. The code outside isn’t. It looks like your code would benefit from event delegation. Don’t attach rock.addEventListener
, scissors.addEventListener
, and paper.addEventListener
, but attach a single listener to an element containing all three and figure out which element has been clicked inside: container.addEventListener("click", ({target}) => { if(target === rock){
… } else if(
… )
… });
3 hours later…
14:45
router.delete("/:id", [authMiddleware, adminMiddleware], async (req, res) => {
res.status(200).json(await User.findOneAndDelete({ _id: req.params.id }));
});
router.get("/:id", async (req, res) => {
res.status(200).json(await User.findOne({ _id: req.params.id }).select("-password -saved"));
});
router.get("/", [authMiddleware], async (req, res) => {
res.status(200).json(await User.find().select("-password -saved"));
});
res.status(200).json(await User.findOneAndDelete({ _id: req.params.id }));
});
router.get("/:id", async (req, res) => {
res.status(200).json(await User.findOne({ _id: req.params.id }).select("-password -saved"));
});
router.get("/", [authMiddleware], async (req, res) => {
res.status(200).json(await User.find().select("-password -saved"));
});
I have such code. Should I use try/catch to handle errors with .findOneAndDelete, findOne and etc? And how to check what those methods return? mongoosejs.com/docs/api.html#model_Model.findOneAndDelete
2 hours later…
17:15
import React from 'react'; const Select = ({ changed, categoryData, selectedCategory }) => ( <> <select onChange={changed} value={selectedCategory.title}> {categoryData.map(({ id, title }) => ( <option key={id} value={title}> {title} </option> ))} </select> </> ); export default Select;
/** * Handle category change * @param {string} event -> ID */ const handleCategoryChange = (event) => { console.log('ID', event.target.id); const categoryById = categoryData.find( (category) => category.id === event.target.id ); setSelectedCategory({ title: categoryById.title, description: categoryById.description }); };
2 hours later…
1 hour later…
20:42
const fetchCategories = async () => { try { const url = 'https://eonet.sci.gsfc.nasa.gov/api/v3/categories'; const response = await fetch(url); const data = await response.json(); if (!response.ok) { throw new Error(' An Error Occured '); } setCategoryData(data.categories); setSelectedCategory(data.categories[0]); setLoading(false); } catch (error) { alert(error); } };
21:45
Hello everyone! I want to build something similar to Webflow/EditorX, but by creating/modifying a local react dev server e.g. an UI wrapper that connects to some local server that will: run create-react-app and create a project; run npm run dev; run npm run build and some deploy script.
I am struggling to figure out what would be the best approach in order to: 1. Create some program that achieves this on the computer, and expose this through a localhost API. 2. Make it secure, and be able to use e.g. an AWS profile 3. Put a paywall in front of it. What would be the best fit to build this "desktop app"? It'd have to be able to install AWS/NPM or maybe ship it somehow (e.g. Docker???). I am banging my head against a wall, any help will be highly appreciated!!
« first day (3697 days earlier) ← previous day next day → last day (1467 days later) »