« first day (3698 days earlier)      last day (1251 days later) » 
05:00 - 19:0019:00 - 22:00

5:44 AM
Hello folks. Modules such as mqtt.js install a binary program on npm install which is subsequently available in the node_modules folder (./node_modules/.bin/ path). How to do something like this for your project?
 
 
8 hours later…
1:52 PM
@MileMijatović define a function in the useEffect callback, not outside
@entithat i hope that password is hashed
i also hope you aren't sending back the password hash (or plaintext) to the user
 
2:18 PM
obviously no
u can notice "-password" option.
 
ah, that seems to be a mongoose thing. Fair enough. First point still stands.
 
@jbis
why ?
I cam calling that function in useEffect hook
 
@entithat You can either use await with try catch or then/catch. In this situation i would use then/catch.
@MileMijatović has to do with how react works but if you want to keep it defined outside then you need to add the function as a dependency. In terms of the url thing i dont understand your question.
 
Ok, then I will define it inside
 
for more information you can read this: reactjs.org/docs/…
 
2:32 PM
What I want to do ? On mount I want to fetch data from two APIs
second is related to the first
 
use fetch with then
fetch('https://eonet.sci.gsfc.nasa.gov/api/v3/categories').then(resp => resp.json()).then(data => {
      setCategoryData(data.categories);
      setSelectedCategory(data.categories[0]);
      setLoading(false);
      return fetch('<anotherurl>');
}).then(resp => json()).then(secondData => {
   // do whatever
});
something like that
 
Great @JBis , I will try your solution
 
2:57 PM
@JBis, like this ?
 const fetchCategories = () => {
    try {
      const url = 'https://eonet.sci.gsfc.nasa.gov/api/v3/categories';
      fetch(url)
        .then((response) => response.json())
        .then((data) => {
          setCategoryData(data.categories);
          setSelectedCategory(data.categories[0]);
          setLoading(false);

          return fetch(data.categories[0].link);
        })
        .then((response) => response.json())
        .then((eventData) => {
          console.log('Event data', eventData);
with a lot of .then chaining
any way to do the same with async/await ?
or this is ok in your opinion ?
 
|| status
 
I am currently alive!
 
|| formatting LinuxUser
 
@LinuxUser Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
 
1 message moved to Trash can
@LinuxUser Please reask with proper formatting.
@MileMijatović i still see no reason for the function, just put it straight into the useEffect but that looks good to me
 
3:01 PM
still works fine without second .then((response) => response.json())
I am not sure why
 
lol, if you remove that then you are logging the response object not the JSON
|| mdn Fetch response
 
Wanting to see why this code does not work?
// Using ES6 syntax
Array.prototype.random = () => {
  return this[Math.floor((Math.random() * this.length))];
}


let arr1 = [1, 2, 3, 4, 5]
console.log(arr1.random()) // Prints undefined
 
@LinuxUser First, I highly recommend you don't add to the Array prototype
Second, the reason that isn't working is because arrow functions don't add a this context. So this in the random arrow function refers to the Window object. Change it to an anonymous function.
||> // Using ES6 syntax
Array.prototype.random =  function(){
  return this[Math.floor((Math.random() * this.length))];
}


let arr1 = [1, 2, 3, 4, 5]
console.log(arr1.random()) // Prints undefined
 
@JBis undefined Logged: 5 Took: 0ms
 
3:07 PM
now it works ^
 
@JBis Thank you.
 
np :)
 
4:02 PM
question about dropzone.js
should not ` paramName: "file"` change the filename of the input ?
 
@real_hagrid it is the input parameter name, f.e. paramName: inputFile will make the form behave like an <input type="file" name="inputFile" /> field
 
so the paramName value should change the file name if changed
 
4:18 PM
no
this is for changing the filename: dropzonejs.com/#config-renameFile
paramName is the name of the parameter the file is send along. File sending works via from / FormData which has a (field)name and a value. The File Blob + Filename is the data, paramName is the name.
 
@JBis you are right , thank you
 
on Server side paramName field is used to check for uploads, f.e. in PHP probably something like $_FILES['inputFile'] but the filename is separate
 
hm I changed ` renameFile: "file", `
but got still an error on server side
 
renameFile: function(file) {return "file";} probably, it needs to be a function, documentation doesn't say wha to return tho so thats an assumption
obviously that does not work for multifile uploads since they would get the same name
 
Do I need try catch if i .catch an error of Promise ?
or I can remove try / catch
like this
    try {
      fetch(url)
        .then((response) => response.json())
        .then((data) => {
          setCategoryData(data.categories);
          setSelectedCategory(data.categories[0]);
          setLoading(false);

          return fetch(data.categories[0].link);
        })
        .then((response) => response.json())
        .then((eventData) => {
          setEventData(eventData);
        })
        .catch((err) => console.log(err));
    } catch (error) {
      alert(error);
    }
 
4:30 PM
@MileMijatović remove try catch
 
Ok
now, below this useEffect(() => {}, []); I have plan to define one more useEffect(() => [selectedCategory]);
 
5:30 PM
Mandem, why my sass giving me a difficult time? I've deleted the node_modules forlder and tried npm install and yarn install and still got this. (node:14588) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
 
5:47 PM
Typescript confusion of the day
// Doesn't work
if (!this.hasSocket) {
    throw new Error("No socket");
}
this.ws.send(...); // ws is possibly null

// Does work

if (!this.ws) {
    throw new Error('No socket');
}
this.ws.send(...); // perfectly fine


has socket has a !!this.ws in it :|
 
@ShrekOverflow Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
For posting large code blocks, use a paste site like like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
 
I don't even know how to phrase this!
 
@ShrekOverflow -- check the actual value of .hasSocket vs .ws, sounds like you're running into truthy-ness, and may need !!! instead of ! so that the type is coerced to a boolean
 
@storsoc Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
@ShrekOverflow
 
5:59 PM
@storsoc Nu nu the code is exactly the same
!this.ws vs !!!this.ws nd somehow the latter doesn't work
 
@ShrekOverflow im confused. Whats the issue?
 
@JBis Typescript infers the former as this.ws is possibly null
the latter its perfectly fine with
I forgot what this check is called :D
 
but how would typescript know that this.hasSocket being true means that ws is not null in the first one.
 
this.hasSocket is literally return !!this.ws
 
@ShrekOverflow i'm not sure typescript can read that far into it
 
6:05 PM
That's quite sad :( it can infer out quite a lot of things
 
Hello again, for some reason second useEffect hook catch an error - SyntaxError: Unexpected token < in JSON at position 0
  useEffect(() => {
    const url = 'https://eonet.sci.gsfc.nasa.gov/api/v3/categories';

    fetch(url)
      .then((response) => response.json())
      .then((data) => {
        setCategoryData(data.categories);
        setSelectedCategory(data.categories[0]);
        setLoading(false);

        return fetch(data.categories[0].link);
      })
      .then((response) => response.json())
      .then((eventData) => {
        setEventData(eventData);
      })
      .catch((err) => alert(err));
  }, []);
probably I have a side effect here
because in first useEffect hook I have setSelectedCategory(data.categories[0]);
but second hook should be triggered just when selectedCategory changes
totally confusion
 
@ShrekOverflow :(
@ShrekOverflow you can always use "!" to tell typescript to fuck off
this.ws!.send
 
Yeah but that just looks bad
i'll create an issue if I can figure this out how to describe
 
6:35 PM
posted on November 30, 2020 by Geo Hsu

The Stable channel is being updated to 86.0.4240.199 (Platform version: 13421.102.0) for most Chrome OS devices. This build contains a number of bug fixes and security updates. Systems will be receiving updates over the next several days. If you find new issues, please let us know by visiting our forum or filing a bug. Interested in switching channels Find out how. You can s

 
about dropzone.js how can I find out the name of the idden input elment? , I need the name on the server side
 
6:58 PM
Hey Mr. Mod o/
 
oh hey folks :)
 
05:00 - 19:0019:00 - 22:00

« first day (3698 days earlier)      last day (1251 days later) »