« first day (3697 days earlier)      last day (1465 days later) » 

00:04
i figured out the problem was that the if statement is only executed when the page loads. So, how can i get around this? should i create a new function checkScore() and put the if statement inside? i tried this but didn't work
or is my only option to put the if statement inside the eventListener?
 
6 hours later…
05:46
hello guys
I am trying to create a chrome extension and I wanna replace some script but when I remove those script or replace the script still doing there behavior such as playing audio. Can anyone help me how it will possible replace webpage script so that those script not do there behavior .
 
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
Hi guys.
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"));
});
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
and how can I decide do I need to use try/catch with async/await or no?
 
2 hours later…
17:15
Hello
Can you help me how to get “key” prop from React element (on change)?
Example
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;
I want to get ID of selected option
I have tried
  /**
   * 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
    });
  };
Only what works for me is event.target.value in case if value={id} but I don't want that
 
2 hours later…
19:32
@user4642212 Thank u so much mann <3<3<3 it worked for me. read up on event delegation and that done the trick
 
1 hour later…
20:42
Hello again
I have one ReactJS specific question
I want to fetch JSON data from two APIs on mount
  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);
    }
  };
  useEffect(() => {
    fetchCategories();
  }, []);
My question is, how to fetch data from the same function fetchCategories , from API which is related to the first url
example, second link should be https://eonet.sci.gsfc.nasa.gov/api/v3/categories/drought
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)      last day (1465 days later) »