« first day (3580 days earlier)      last day (1351 days later) » 

12:28 AM
So, I have a question about Gatsby, GraphQL, and JSX...
 
@M312V 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.
 
Why do all examples use staticQuery inside function components instead of just doing a query inside a page and pass it to components?
 
 
1 hour later…
1:54 AM
Hello, I have a problem with decorators, I need the decorator does not overwrite the superclass method.
 
@robinsonortiz 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.
 
 
11 hours later…
12:33 PM
Hi all
 
 
2 hours later…
2:31 PM
@JBis are you here by any chance?
 
@Wietlol i'm always here!
morning o/
 
ohai
I need your help
JamesBot runs as a dedicated application, doesn't it?
 
yepo
 
as in... not as a script in the browser
I saw some heresy you did with the cookies to be able to connect to SE
what was the error you had when you didnt do that stuff?
something like "You must login to post"?
 
@Wietlol that specific thing had nothing to do with SO. The lib I was using sometimes saved invalid JSON and it create issues next time i ran the app.
 
2:40 PM
well... I am trying to make a nodejs application that can send messages and edit messages in SO chat
wait... I am a giddy goat
 
Yeah, so you need to save the login cookies when you login for it to work.
People seems to have a lot of issues saving it properly.
 
hmm...
 
did not know that storing cookies is difficult
put in a jar? 😁
 
probably a dumb JS question: I'm printing out <p> nodes to the browser using document.write(), but because they're not actually appended to the DOM, I can't target them via CSS. Would appending <p> tags to the DOM allow me to modify the styling with CSS? I'm trying to avoid changing CSS in JS, but if appending nodes won't work, I guess I'll use JS
 
what I did was just translating what Wietbot currently does to node and just try it
 
@Tiffany you can append <p> in a different way
 
async send(roomId, messageText) {
    console.log("send", roomId, messageText, this.siteUrl);
    return request({
        method: 'POST',
        uri: `${this.siteUrl}/chats/${roomId}/messages/new`,
        jar: this.cookieJar,
        form: {
            text: messageText,
            fkey: this.fkey
        },
    });
}
this appears to not do the trick though
 
@Tiffany also don't use document.write
 
look for document.createElement which gives you a HTMLElement. With that, you can simply element.appendChild(...) to put that in the DOM tree
 
thanks
 
2:46 PM
@Wietlol it does, you need to make sure the cookies are there
 
@JBis it was the closest I could find to echo :X
 
document.write might be useful but is a dangerous function
 
hmm...
how can I read the cookies from a jar?
 
@Tiffany yeah, you shouldn't be echoing. Whats your backend lang?
 
@JBis eh
 
2:47 PM
nothing right now, it's a code challenge
 
@Wietlol are you in javascript?
 
node-js, yes
 
I'm just trying to make it pretty for the people reviewing
 
what lib are you using?
 
I tried using const cookieJar = request.jar();
 
2:48 PM
jquery is allowed, it appears, but I try to avoid using jquery
 
const request = require("request-promise");
 
use those document.createElement instead then
 
yeah, that's what I plan to do :)
 
@Wietlol ok, that lib is depreciated fyi. But you need to attatch it in the request github.com/jbis9051/JamesSOBot/blob/master/src/platform/…
 
2:49 PM
it has also - by coincidence- an example you can use
 
if it is deprecated, then I would use a newer one
what is currently the best way to send http requests in node-js?
 
fetch
 
thanks @KarelG and @JBis
 
Is there a way in Chrome/FF dev tools to see all the event handlers on an element?
 
2:51 PM
Yes.
 
How do you do that?
 
the event listeners tab
it's right next to dom breakpoints and computed/style
 
Chrome has event listeners tab, FF has events next to the actual dom element in the HTML viewer
 
i like that feature tbh
 
Found it! Thanks, guys
 
2:53 PM
I think FF's dev tools are better than chrome for most things
ff understands react handlers natively, chrome doesn't
 
firefox isn't chrome, so it's by default not as good
 
i use chrome for work but it happens that I open FF to figure out a js problem
 
Firefox users, assemble!
 
it is a bit more informative
 
i've fixed multiple flex bugs cause ff tells me why its doing what its doing
 
2:55 PM
in contrary to that, chrome has better perf / mem scan
 
^ thats true, but i've never needed to use that
 
at home, I am an avid FF boy
 
node --version : v8.11.4
npm --version : 5.6.0
are these ancient?
 
i think we're on node 12/14 now
 
I tried using the fetch library, but it now has errors "Unexpected token import"
guess I have to update :D
hmm...
> Cannot use import statement outside a module
 
3:10 PM
you can't use es6 imports in node natively
 
SO says replace import with require
 
exactly
 
node says "Must use import to load ES Module:"
 
whats your code
 
const {fetch, CookieJar} = require('node-fetch-cookies');
 
3:11 PM
that should be fine
 
at least... the error says on the require('node-fetch-cookies')
> node_modules\node-fetch-cookies\src\index.mjs
 
ok don't use that lib it isn't setup properly
just use normal node fetch
then you can do req.headers.cookies or something,
 
also, how do I easily run an async function with node?
with node test.js
in test.js, I cannot use await on the top level to invoke an async function
 
?
that seems like such an add question to me
you can create an async function, await inside it etc, then call it in the test.js file, but if you want other things that include test.js to... wait for that to finish, you'd instead need test.js to return the async function and have the other things call the function.
just depends on what your goals are
 
run it via the command line
so, if I wrap that function I want to await in another function, I end up with this
test.js:

async function wrapper() {
    await actualFunction();
}
wrapper();
but then wrapper isnt awaited
 
3:25 PM
why should it be?
 
and I cant do await wrapper();
 
You can do wrapper().then(cb)
 
cb?
 
callback, any function
but, why do you need to await it?
 
iDunno
 
3:27 PM
do you need to do something when it's done?
 
wouldnt node otherwise be able to exit before the function is actually finished?
 
no, node only exits when everything is out of the stack
 
3:43 PM
not sure if this fetch api is any improvement... I will revert to using request-promise
 
request-promise extends request, which is no longer receiving updates
just fyi
i wouldn't suggest getting comfortable with it if you intend to use any of this code for something longterm or important
 
fetch is actually pretty good imo
its super easy to do just about anything with exception of aborting
 
or cookies
 
cookies are easy too
response.headers.cookies
holy shit amd is doing well
 
well... I have the request-promise version working now... I think...
 
3:59 PM
good news is the concepts are the same across both
only thing that really changes is how you pass the options around and handle the response
http is http
 
speaking of http, i still think my http over websockets is a good idea
 
4:42 PM
I am totally bamboozled
async function editMessage(event) {
    console.log(event); // {"messageId":50121364,"messageText":"b 😁 d"}
    const messageId = event.messageId;
    const messageText = event.messageText;

    await callStackOverflow(async function (client) {
        await client.edit(messageId, messageText);

        // async edit(messageId, messageText) {
        //     console.log("edit", messageId, messageText, this.siteUrl); // edit undefined undefined chat.stackoverflow.com
        //     return request({
locally, this works
on the server, it doesnt
locally, messageId and messageText are the correct values, on the server, they are both undefined
console.log(event); // {"messageId":50121364,"messageText":"b 😁 d"}
const messageId = event.messageId;
const messageText = event.messageText;
console.log("1", messageId, messageText); // 1 undefined undefined
even shorter version
what is this heresy?
wait...
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah
it is a string, not an object
 
 
1 hour later…
5:48 PM
posted on August 04, 2020 by Prudhvikumar Bommana

The Dev channel has been updated to 86.0.4221.3/.4 for Windows & Mac, 86.0.4221.3 for Linux platforms. A partial list of changes is available in the log. Interested in switching release channels? Find out how. If you find a new issue, please let us know by filing a bug. The community help forum is also a great place to reach out for help or learn about common issues. Google Chrome Prudhviku

 
You're using a whole lot of async/await there that doesn't really accomplish anything
does callStackOverflow return a promise?
does it return anything?
kinda weird to see a function both expect a callback and be async
being async usually makes the callback not necessary
kinda the point of it
 
uh oh
James may go down, bad storm
 
6:11 PM
no
2
 
doing this as a gist instead of jsfiddle cause it's a code challenge and I feel bad ... am I able to appendChild like this, nested inside of a loop and a conditional? I'm using developer.mozilla.org/en-US/docs/Web/API/Document/… as reference, but their example isn't nested in a loop/conditional
I'm misunderstanding something, but not sure what
 
6:28 PM
yeah, that seems mostly fine... though i don't see where you're doing anything with p in the end.
fiz buz?
 
yeah, basically
 
 
1 hour later…
7:37 PM
kinda sorta figured it out ^
 
8:26 PM
Using react. My child component is a rich-text-editor and contains methods to manipulate text. Parent component has toolbar buttons to trigger text manipulation. How should In invoke child methods from parent component's buttons?
 
 
1 hour later…
9:41 PM
Anyone know whats the proper protocol for using a github repo as an npm package?
I have a repo with react components, structured under src/components, and I only want that to be available when used as a package, but I don't want to publish this on npm as its only going to be used by this github org (so it makes sense to me to just use the github url when installing)
 
Just link to the repository from package.json instead of publishing it on NPM
 
@CodedMonkey 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.
 
You can just run npm install username/repo#branch
Can somebody please create a tag for the Proton Native framework?
There are literally zero questions for this framework that's already 2 years old, why? :(
 
@CodedMonkey When I do that it pulls down the entire repo, but is there a way such that it only pulls the down src folder and node_modules so things like test etc aren't there? Or is the right way to include an index.js at the repo root so i can import the components?
 
Well you can create an .npmignore file and there are settings in package.json to specify which files should be downloaded
but I'm not 100% sure that works for non-packages
 
9:49 PM
Hmm so if I wanted to do something more advanced like treat the src folder as root id need a build process and host that somewhere?
 
If this doesnt help you i cant help you: stackoverflow.com/questions/37857149/…
Can somebody please create a tag for the Proton Native framework?
There are literally zero questions for this framework that's already 2 years old, why? :(
Not even mods in here? lol I guess I'll take my question elsewhere? The dark side of the internet? Who knows
 
i mean
 
Hmm I think I figured out something that works, I think the "main" field of package.json specifies the file that is hit in import from "package", so i guess it doesnt matter that the rest is downloaded since I can easily access the files i need to import
 
mods aren't needed to make tags
Why does that tag need to exist?
 
it just would be useful
I forgot I can just tag it javascript -_-
 
10:01 PM
If there are zero questions for this framework then it sounds like it wouldn't be very useful
Perhaps the framework is just so intuitive that nobody has any questions about it
 
The dream
 
there's maybe a half dozen questions that mention it
several are close worthy
 
10:44 PM
Anyone know how importing like this works:
import Button from "react-bootstrap/Button";
I.e. is there a defined way for accessing a subfolder inside a package? I'm trying to do something similar so I dont have to import all my stuff like
import {thing1, thing2, thing3} from "package", i'd prefer
import thing1 from "package/thing1"
 
11:01 PM
Nvm i got it! For anyone interested, neutrino js component preset builds everything in src/components to build, with each component as an entry point. I then made a github action that builds and deploys the build folder to a dist branch, and on the project i wanted to use it i just did yarn add user/repo#branch to pull down the buil;d files, in which i could do import thing1 from "package/thing1"
 

« first day (3580 days earlier)      last day (1351 days later) »