« first day (3454 days earlier)      last day (1477 days later) » 

12:04 AM
Nvm got that
 
See? You've got it handled
 
 
1 hour later…
1:25 AM
 
 
6 hours later…
7:30 AM
0
Q: Get the access token in localStorage generated by MSAL.JS and put it in Axios

Joker BenchGood day, I'm trying to implement MSAL.js in my application. Basically, I'm able to implement the msal.js and log in using my email from the AD. I also configured the msal to save my tokenid and accessToken in my localStorage The accessToken is working in my backend because I tested it using P...

 
@JokerBench 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.
 
help senpai
 
how are you adding this to your localstorage?
 
it adds automatically by msal.js
 
from what I can see you aren't supposed to access the localstorage rows manually
 
7:39 AM
so how can I attach it on my axios headers?
 
hmm I haven't used msal. I can't help, sorry
 
I'm basing on this sample github.com/AzureAD/microsoft-authentication-library-for-js/tree/… but it has no axios that's why I'm looking for answer
@forresthopkinsa I understand
 
8:01 AM
Hi All
im looking to have a validation layer which will validate the object
i have explored JOI and validator.js
can anyone suggest which is a better option to go with,/
my api is in nodejs
 
 
1 hour later…
9:17 AM
I am studying react JS and i am reading the state and lifecycle methods...
I could't understand what difference the class is making here. Documentation says...
"Reusable"
how it's reusable is what I am trying to understand...
 
9:52 AM
and typescript
 
@CommonMan a website usually consists of multiple pages. Now, imagine that there is a navigation bar
are you going to re-write that navigation bar for each page? Again and again?
no, that's what is done here: you make a new component: SiteNavigationBar
you define there how it is shown, visually and added functionalities (such as extra highlight)
then you cna simply use the same component on all pages by writing it once
<SiteNavigationBar var1=... var2=... />,
 
10:12 AM
Hello
 
@icantprogram 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.
 
Can someone help me with my project
I'm trying to render a file from another folder to serve as a main landing page after logging in on my website
but I don't know how I can do that
 
 
1 hour later…
JBK
11:14 AM
@icantprogram can you send some code to look at?
 
11:30 AM
Yes
THis is where I render the dummy page
const express = require('express');
const router = express.Router();

//Main page of login/register
router.get('/', (req, res) => res.render('welcome'));

//Main page of movie site goes here
router.get('/movie_main_page', (req, res) => res.render('movie_main_page'));

module.exports = router;
Then i have a server.js file that I want to run in another folder
@JBK
I'm using EJS to render the dummy file, but the frontpage of my website is HTML
I'm using Node.js for both folders, I don't know if it's possible to merge the servers or something
I can render movie_main_page fine, but I can't figure out how to re-direct it to the frontpage
the server.js file in frontpage does everything like rendering the HTML file for the frontpage
this is the directory
i.imgur.com/nNWhVt1.png
 
12:17 PM
morn o/
 
\o
 
12:29 PM
Heya may someone has a better idea :D
i try to use promises for image loading.. it works for images that fail as expected, but all images that loaded its not returning reject or resolved :(
this is my code so far
waitForImageToFail(imageElement) {
        return new Promise(resolve => { imageElement.onerror = resolve }, reject => { imageElement.onload = reject });
    }
 
The argument for a Promise is a single executor function. That function can take your resolve and reject callbacks as arguments
 
@CrissCrossCrass you need to check the Promise documentation. As Kramb has said, its constructor expects one function that can handle two parameters: resolve and reject
however, using new Promise is not so encouraged nowadays
 
oh really? damn
 
and that's not a proper way to load images. I advise you to use Fetch api
it gives you the image as promise object with better control
 
i thought it would be the perfect opportunity to learn promises
okay so
new Promise(executor);
new Promise(function(resolve, reject) { ... });
 
12:41 PM
sure, feel free to use that. I am just saying: try to not use it in production 😉
 
so in my case then
new Promise(function (resolve, reject) {
            if (imageElement.onerror) {
                return resolve;
            }
            return reject;;
        });
this will work?
 
learning stuff is doing it yourself and learning from mistakes :P
 
so try it
 
nope its not working.. all loaded images have still the "pending"
 
12:43 PM
you have to initialize your resolve/reject functions. Either do that in the promise or the caller
 
You know that ImageElement has these callback handlers
 
okay how can i initialize then? my caller would

let itemMainImage = this.waitForImageToFail(loaderImage).then(() => {
                console.log("Couldn't load main Image: " + randomImage);
                aImage.src = "";
                this.failedImagesSKU.push(randomSKU);
                this.failedImagesURL.push(randomImage);
            });
            this.usedPromises.push(itemMainImage);
via catch? or ?? iam confused now :/
ahhh as a callback, okay now i have it, thanks a bunch guys :) its working
 
Expecting Microsoft to write good js, tssss

https://github.com/microsoft/TypeScript-React-Conversion-Guide/blob/master/TicTacToe_JS/src/gameStateBar.jsx#L24
 
12:59 PM
@dievardump both statements are not correct tbh
 
yeah I was just pointing
 
if you have used anon functions, don't expect to see it being removed when using removeEventListener
 
That's what I was pointing at
I decided to start looking at TS, but the first example I see has bad js, tsts
 
@dievardump 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
1 message moved to Trash can
 
tsss ` ` ` does not work?
And Caprica's dead? :(
 
1:06 PM
|| echo I'm the improved version
 
I'm the improved version
 
JBK
@icantprogram so correct me if I'm wrong, what you're trying to build a landing page that serves as a login page and then once a user logged in display the actual home page for the website?

If so you will need to manage users yourself or use a 3rd party and when connections try to access your actual home page you'd need to have a check in place to see if the connection is authorised or not.

There are plenty of tutorials online, here's one I just skimmed through and looked fine to me -
https://codeshack.io/basic-login-system-nodejs-express-mysql/
the first one includes setting up a DB and registering users and such
Here's a second tutorial from auth0 themselves, this login system uses 0auth as a 3rd party.
https://auth0.com/blog/create-a-simple-and-secure-node-express-app/
 
> That's about all we need to do for a basic login system, remember this is only a basic solution, I wouldn't recommend using it for production purposes
then why even bother?
I can highly recommend using an identity provider
 
JBK
You'd have to ask the tutorial author I guess 🤷‍♂️
I think it is a good introductory and believe getting your hands dirty (even if it's not a fully featured, tightly sealed system) helps you learn better
I also provided a link to auth0's tutorial
 
ye... people dont care about those things
they just see the tutorial "basic login system" and be like "basic? nice, I need that"
they wouldnt even read the conclusion part
to show how difficult something is, you have to show how difficult something is, not how broken something is when you avoid the difficulties (especially when you put is somewhere where 80-90% of the people wont even read it)
 
1:17 PM
$$
 
probably
I hate humans :(
 
I pushed something to github pages and the website updated however the images are getting a 404. I've checked the commit and they show that they are ther, however I get a 404 for the website. I checked the path and it is correct.
 
it's essentially a form of creating click-baity useless content for the sole purpose of ad profit
 
what is an ad?
 
which... defines most tech blogs
 
1:19 PM
 
which site?
codeshack.io definitely has ads
 
and me am sitting here without adblocks
 
i mean, if you're saying ads don't exist because you have adblock, you're missing the point, lol
 
ye, but I dont see ads, so I cant really see which websites are cool and which ones arent
 
it goes back to... why is this person writing this blog post/tutorial? clearly, in both presented cases it's to attract visitors, and for auth0 it's also to inform visitors of their products.
 
1:25 PM
the only ads I can see are when put behind a proxy of the site owner
 
$$ in both cases
 
the sites that are cool (without ads) probably wont get any profit from putting ads on their website
 
oh found the issue, i was being stupid as ususal. Images were not in build dir
 
hmm... even google.com has an ad
i cant see it tho
 
Does Vanilla JS Mean No jQuery?
 
1:36 PM
yes
no frameworks essentially
 
as in: plain jane 90's javascript?
 
lol
just follow the recent ecma standards
 
i guess not
ok
 
however, it is not a big problem if you want to use jquery
it is just ... not smart to do so
 
I was just confused for a moment here
 
1:37 PM
it is still in use because of legacy code
 
b/c of a following comment
on linked page
ie:
css-tricks.com/value-bubbles-for-range-inputs/… sounds like last one was jQuery enhanced
going with first example
"Vanilla"
Thx
Could use help on Vanilla example
with make JS applicable to ONE use case
that part has me fumbling
 
I wonder if choclat---yup chocolate js is a framework
 
:P
some people had to find a name for their plugin/framework
fyi, there are multiple "chocolate" plugin/framework AFAIK
 
1:46 PM
honestly, theres probably a framework for generating names for frameworks
 
😂
 
Ah Ha I see how to strip it down to one use case
I think...
Over n Out Thx Karel
 
@Kar
you said Fetch api would be the better way, but how would you deal with cors errors? :o
 
handle it?
check the request/response headers.
mdn has a nice page about CORS
bit long page but an essential read
 
2:00 PM
okay... then more stuff to read :> thanks i guess?
:P
 
hmm
what does fetch api have to do with cors
i c, image loading.

i wonder if `mode:'no-cors'` would still result in it being cached
... why is that not inline code
 
dunno, but this was what iam looking for too :D
 
should be easy to test
 
what does cors have to do with cache?
 
nothing hopefully
 
2:21 PM
if js/html has taught me anything, it's to not trust the expected outcome to be the one you get.
 
sidenote, i've been using typescript for the past couple days and loving it
 
2:36 PM
💯
 
2:48 PM
quick question, can you return from a catch block into another then block?
Im trying to set a var based on whether something was successful or not (then vs catch) and then I want to do something after that var has been set
 
no
if you're asking what i think you're asking
that .then block has already returned
 
Hmm, so would I have to wrap my entire func.then.catch block inside of another promise to do what I want?
 
not necessarily
got some code?
 
sure im whipping up an example rn
 
you might be falling into an anti-pattern
 
2:55 PM
Hmm ok i revised what i originall was doing, lemme put this in a pastebin
Essentially when I receive an email through a webhook, I want to parse it. First I create an email with the basic info I have, and then try parsing. If parsing succeeds, change the email to include the new parsed info. After parsing/failure, send the email
 
have the .catch return what you want passed to a .then that you add after it, which sends the email
.then(...).catch(...).then(...)
 
And have returns in both the first then and the catch?
 
yup
 
Ok thanks!
 
it just passes what you return on down the chain
 
3:01 PM
Ah ok, so if the first then succeeds, it means the catch never happened and vice versa, so having returns in them will make sure the final then gets the correct message
 
correct
 
Thank you!
 
3:34 PM
Does anybody know of an easy to explain way to use jquery to move a cursor to the end of a content editable element. Preferably with something like
```$element.moveToEnd();``` or ```moveToEnd($element);```
 
jquery doesn't have such a tool
 
Hello, anyone could help me? I'd like to get every img in a page. (In this case twitter), but it doesn't work for twitter but it does for other pages
 
@GeorgiaFernández 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.
 
@KevinB perfect answer. It was easy to explain and is probably the most correct answer there is.
@GeorgiaFernández Are you trying to store them in an array, or something else. What is the use case?
 
@GeorgiaFernández 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.
1 message moved to Trash can
 
3:47 PM
@TylerLazenby Sure, I'm using document.getElementsByTagName("img") and storing it in an array, after that I use a loop for get every src, and as I said it works for other pages, but it doens't work in twitter
 
what kind of element is this "twitter" element?
brb going to grab something btw
 
I mean, twitter website
 
how long are you waiting before you run said code?
 
Who? me? if so, time enough I'd say, more than 10minutes
for some weird reason it works once, instantly, but now it doesn't :/
 
@GeorgiaFernández Twitter is a SPA that loads stuff dynamically with JS. You are likely going to need something like puppeteer if you would like to automate it.
 
4:28 PM
I was going to say that
 
 
2 hours later…
6:26 PM
Anyone with a nice "start with TypeScript" tutorial or something? What is found as first results in google (or on the TypeScript website) are not really interesting to follow
 
i started by adding it to an existing project and then proceeding to fix all the errors
 
This person is pretty great at teaching youtube.com/watch?v=BwuLxPH8IDs
 
6:55 PM
anyone have any suggestions on how to best read minified js?
 
click the tidy button and hope for the best
 
yeah that helps a lot but very difficult without good variable names
 
 
2 hours later…
8:28 PM
Would anyone here be able to provide some input on this question regarding Electron? Their documentation seems to be lacking:
https://stackoverflow.com/questions/60959176/electron-purpose-of-setapplogspath
 
@D3V1L0M3N 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.
 
-_-
Oh, hey bot
 
> Calling app.setAppLogsPath() without a path parameter will result in this directory being set to ~/Library/Logs/YourAppName on macOS, and inside the userData directory on Linux and Windows.
 
Not related.
I am questioning about a specific function which is lacking information on its use-cases.
 
right
a function that you think would log console.logs, right?
and are wondering what it actually logs?
 
8:34 PM
Not exactly. I want to know the purpose of the function as shown above.
I have no difficulty creating and appending a log file.
 
i mean
the docs state the purpose
:shrug:
it essentially sets a property. What electron does with that is something else
 
Yes and no. The documentation states it sets the directory for your Applogs. There is no information on what is considered an "App Log" and what sort of things would be logged..
 
would it not make more sense to research your goal rather than some arbitrary function?
All that function does is tell the app where to place the logs. what logs, is in another castle
 
"what logs, is in another question"
- That *is* my question
 
8:55 PM
i mean
can't you just run it and see what it logs
my point is that function has nothing to do with what is logged
it just sets the directory the log will be placed in
what is logged is likely handled by something else
 
9:14 PM
I did experiment with the function to see what it'd do - but since nothing happened I came here to question it's seemingly useless purpose. Only to be reminded how toxic this platform is - people down-voting questions without actually leaving any input for why they decided to downvote and how the question could be refined or improved.
My point is, I come looking for an answer about a function which is lacking documentation for it's use cases and what is does - only to be shunted in a completely different direction.
 
it's not lacking documentation though
it... doesn't do anything other than what the docs state
lol
hence the... research what you wanted out of it, not why it isn't doing it or what it's supposed to do.
 
Yes, you are right
 
@ArdentCoder 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.
 
Lol I am new to this chat feature so just thought of peeking in some active rooms :P
Since you've asked me to post a question, why is JavaScript a bad language?
I'm coming from a C++ background hehe
Sorry, I didn't notice that you are a bot XD
 
9:42 PM
JS is a bad language because it doesn't have automatic memory management like C++ does
oh wait
 
DAMMM
JS is pretty good ever since async/await was added
 
we've been getting more people stumbling over promises in this room ever since async/await was added
 
lol not sure why
 
kevinb will gladly explain the problem if you let him
 
10:25 PM
learning async await was fun, took a bit but once it clicked it opened so much
welcome @ArdentCoder o/
 
10:41 PM
green screen live with canvas?! this is pretty cool developer.mozilla.org/en-US/docs/Web/API/Canvas_API/…
 
that is very cool
the possibilities of canvas are limitless
 
posted on March 31, 2020 by Srinivas Sista

The stable channel has been updated to 80.0.3987.162 for Windows, Mac, and Linux, which will roll out over the coming days/weeks. A list of all 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 i

 
Can't believe we're still on m80
I've been waiting for fixes that landed in 82 for like a month
 
Lol thanks @JBis
 
That is extremely interesting @JBis, I'm already thinking of tons of ideas now. Thanks for taking away my focus from what I'm supposed to be doing (client work) lol!
 
10:56 PM
haha np
 
Random question, anyone here ever use Node/Socket.IO in conjunction with Slack? All of my searches so far keep resulting in either building a slack clone or channels in slack for discussing socket.io.
 

« first day (3454 days earlier)      last day (1477 days later) »