« first day (3755 days earlier)      last day (1176 days later) » 

12:37 AM
 
12:49 AM
Best ElectronJS boilerplate? Maybe something with UI elements like Material/SemanticUI(dead)
 
coldfusion
 
1:02 AM
Uh, I dropped CFM in 2001 :|
 
 
4 hours later…
4:41 AM
Hi all, first time i come there
 
@VuiTeenmax 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.
 
Every one there?
 
Welcome @VuiTeenmax.
 
 
5 hours later…
9:56 AM
Is it better to ask a question on stackoverflow or is better to post on discord. I know you can get answers much faster on a chat application, but the answers are not very searchable, where as with stackoverflow the answer is indexed by search engines?
 
@HarryKruger 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.
 
10:12 AM
@HarryKruger I'm not fond of asking over Discord or chat applications in general. Mostly because it feels inefficient. Then again, I hardly ever ask questions on SO - search out a problem and most of the time resolve it before needing assistance. However, that's just me. I'm aware that other people can work differently. Do whatever is more effective for you. However, be aware that SO has a high standard for questions. The expectation is to ask a good question, and that's not very easy.
 
 
1 hour later…
11:24 AM
Hey guys I have this issue here the ajax call is running expectedly and printing correctly, here
const run_call = (value) => {
        fetch('/api/check_username', {
            method: 'POST',
            headers: {
                'Content-type': 'application/json',
            },
            body: JSON.stringify(value),
        })
        .then(res => res.json()).then(res => {
            if(res['error']) {
                console.log('returning false');
                return 0;
            } else {
                console.log('returning true');
                return 1;
            };
but when trying to throw an error here:
const validateUsername = (value) => {
        console.log(run_call(value))
        if (run_call(value) == 0) throw new Error('Username invalid use a different');
    };
it isnt throwing correctly
I have tried returning true and false
I have tried it as
const validateUsername = (value) => {
        console.log(run_call(value))
        if (!run_call(value)) throw new Error('Username invalid use a different');
    };
 
@Kwsswart 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.
 
@Kwsswart you don't return anything from run_call. Change the first line to return fetch('/api/check_username', and then you also need to await run_call(value) to get the plain value from the promise.
 
@VLAZ Thanks man but when placing
const run_call = (value) => {
        return fetch('/api/check_username', {
            method: 'POST',
            headers: {
                'Content-type': 'application/json',
            },
            body: JSON.stringify(value),
        })
        .then(res => res.json()).then(res => {
            if(res['error']) {
                console.log('returning false');
                return 0;
            } else {
                console.log('returning true');
                return 1;
            };
I am receiving
C:\Users\kwssw\OneDrive\Documentos\Workspace\React\phonebook\src\auth\registerComponents\Username_field.js: 'await' is only allowed within async functions and at the top levels of modules (29:12)

  27 |     const validateUsername = (value) => {
  28 |         console.log(run_call(value))
> 29 |         if (await run_call(value)) throw new Error('Username invalid use a different');
     |             ^
  30 |     };
  31 |     return <FormField type="text" validator={validateUsername} {...restProps} />
 
You need async (value) => /* ...*/
 
from the react errors
Hmm I get what you are saying but not its completely broken.. maybe I need to think how to redo this as the aim is to send a ajax call to flask server and the serer returns json of error and message
the plan is if returning message dont display but if returning error throw error to be displayed in form
async await sends as uncaught error
 
11:58 AM
Hi, is there anybody that I can ask a question about generating CSV from Javascript ?
 
@dani 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.
 
Here's my question link;
1
Q: How to add new line in CSV generated by JQuery

daniI have a list that needs to be generated as CSV. Here it is; [101, true, P, b, br, 2020], [101, true, P, 20, br, 2020], [101, true, P, b, breach, 2020] And I wrote this to convert it; var link = document.createElement('a'); link.id = 'download-csv'; ...

 
12:28 PM
can anyone help me with this please
 
@bhupathituraga 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.
 
0
Q: Refused to connect to 'wss://live.mysite.com:3000/' because it violates the following Content Security Policy directive:

Bhupathi office if (navigator.mediaDevices.getUserMedia) { navigator.mediaDevices.getUserMedia(constraints) .then(stream => { localStream = stream; document.getElementById('localVideo').srcObject = stream; }).catch(errorHandler) // set up websocket and message all exis...

 
0
Q: Can't implement dropzone.js to an existing form

randomdudeI'm trying to implement the dropzone.js to my existing form, which has a lot of input fields, select options, etc. I tried to follow this answer: https://stackoverflow.com/a/35275260/13695248 but all I earned is if I press the send button, literally nothing happens. No error or anything, it just ...

 
@randomdude 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.
 
12:47 PM
can anyone take a look at my question pls? No idea what im doing wrong
 
Howdy, I'm trying to remember what's the name of this language construct in JavaScript
it allows to pass context to anonymous functions, like so:
let bar = 'Bar!';
function(foo) {
  alert(foo); // Bar!
}(bar);
 
@LucasBustamante 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.
 
|| mdn IIFE
 
@LucasBustamante ^?
 
12:55 PM
Ahhh, it makes sense now
so it's not a callable anymore when I do this....
fits my use case anyway, but good to know
thanks!
 
||> ((foo) => console.log(foo))('Bar!');
 
@JBis undefined Logged: "Bar!" Took: 0ms
 
 
1 hour later…
2:10 PM
||> re = /(?i)a/
 
@VLAZ "SyntaxError: Invalid regular expression: /(?i)a/: Invalid group" Logged: `` Took: 36ms
 
Invalid group? The (?i) switch should be enabling case-insensitive mode.
 
you put the mode after
/a/i
 
I know I can use the flag, but I wanted to use the switch within the regex itself. The flag makes the whole pattern case-insensitive, I wanted to just make a part of it. You can enable/disable the mods with (?i) and then (?-i). At least in other regex flavours. I thought that was also available in JS
 
`courseObj.topic = {};
course.topic._id = topic._id;
course.topic.title = topic.title;`
Is there any shortcut for the above codes in ES6?
 
2:17 PM
@randomdude you are not calling the done function in accept so your Queue is always empty, see dropzonejs.com/#config-accept
 
@SmithDwayne not very much shorter: ({_id: courseObj.topic._id, title: courseObj.topic.title} = topic)
 
can we not use require in typescript ?
 
i mean
 
You can space it out to look better but it's not much better. jsbin.com/qewidoposu/edit?js,console
 
@VLAZ: I made a mistake. Sorry. Code is
courseObj.topic = {};
courseObj.topic._id = topic._id;
courseObj.topic.title = topic.title;
 
2:26 PM
What is the difference?
 
course.topic.. and I understood your answer.. Thank you.
 
@user2869844 you can but don't
 
@SmithDwayne Probably worth noting - if you want to copy everything from topic (so, assuming _id and title are the only properties), then you can do courseObj.topic = {...topic} or courseObj.topic = Object.assign({}, topic)
 
@VLAZ: I don't want all the properties of topic object. Only _id and title
 
@JBis what are the downsides ?
 
2:33 PM
es6 imports are built into the spec, require is magic that may or may not be supported on various platforms
 
@JBis i understand, thanks but there's nothing like it's not compatible right ?
or not possible
 
wdym?
 
for example someone told me i can't import interface with require in ts
 
no idea, never tried
 
okay
 
2:36 PM
but that makes sense it wouldn't work
 
@SmithDwayne You can have a small helper function that only takes the properties you want from an object. Here is a sample implementation although you can also use _.pick from Lodash/Underscore or Ramda's R.pick
 
@VLAZ: Thank you.
 
whats with people loving lodash? i've never used it and never felt i needed it
 
@makadev Just added done(); right before the end of accept function, but still doesn't do anything on submit
 
2:42 PM
Lol nvm
facepalm
 
@JBis It's a useful collection of tools for common tasks. Also helps cross-browser support (because of course: IE). Post ES6 and as older browsers started falling off the map, it's not a big need. If it's already included as a dependency for you project, you may as well use it for other tasks. If it's not, it's honestly not big of a loss nowadays.
I tend to advocate making the function equivalent of what Lodash already includes, as it's quite simple in many cases. You don't need the additional syntax Lodash enables most of the time.
 
@randomdude basically your example + added done() call: jsfiddle.net/uwLxb9yv it does send
 
So Lodash is the non-DOM version of jQuery
 
I've used it for a few of it's utility methods in the past
 
Basically.
 
2:48 PM
nothing it does can't be done on your own
 
Bunch of array and object conveniences like map/filter
 
just like any other lib
 
i have seen it suggested for checking deep object equality and creating deep copys of objects, two things that are a pain
 
merge is probably one of the few things I'd bring the library over. It does a deep merge of objects.
 
I've used it mostly for when i still had to deal with IE11
but... i haven't really touched javascript in nearly a year...
 
2:51 PM
too busy with coldfusion?
 
@KevinB the horror...
(/s)
 
i no longer have to maintain a website or frontend, so it's all coldfusion now
 
Just rewrite all the ColdFusion to JS.
 
thought about it
but there's no real benefit to doing so
 
i've been trying to get into new langs, wanna learn C++, Rust, Go, and C#.
 
2:52 PM
Rust is supposed to be really good.
 
C++ is very difficult for me
 
if there was any chance at all that we'd ever bring on additional devs i'd think about it
 
C++ I studied in Uni a bit but never wrote much in. Even the C++ assignment I had to do was mostly hacked C.
 
@VLAZ everyone seems to love it
 
but at this point... i find sticking with coldfusion to be the path of least resistance
 
2:53 PM
@KevinB is it just you?
 
yup
 
C# is meh. It's not bad but since I come from Java and JavaScript background it's basically the same. Nothing much new.
Even though it was JS that got some C# features and Java also got lambdas after C# had them for a while.
 
C# seems much better than Java from my extremely minimal experience.
 
the only real problems coldfusion causes me is java
 
*shrug* not sure which one I'd recommend. They are mostly the same to me.
 
2:55 PM
For a high level language, Java seems so antiquated
 
@makadev If I write a bad url, which isnt the upload.php then it throws an alert message that it can't find the file. But if it's upload.php where it should upload, nothing happens.
 
It's enterprise-y. It's...like a running joke.
Also, Oracle are taking it in a weird direction. I've not actually followed much what happened after Java 10.
 
And I still hate making people install java to run apps
I know you can bundle it but most don't.
 
.then(data => {
          console.log(data.d.results);
          const html = data.d.results
            .map(user => {
                return `
                <div class="user">
                 <p>${user.Team}</p>
                 <p>Offensive Report: ${user.OffensiveReport}</p>
                 <p>Defensive Report: ${user.DefensiveReport}</p>
                 <p>Special Teams Report: ${user.SpecialTeamsReport}</p>
                 <p>Coaches Notes: ${user.CoachesNotes}</p>
                 </div>
 
in a way i'd like to learn java, as it'd give me another toolset i can use alongside coldfusion (from CFML i can directly access java) but...
 
2:57 PM
Yeah, the weird licensing now also makes it hard. I am not sure if bundling is allowed and under what conditions.
 
I fetch all these items from a list the Team,OffReport,DefReport etc. when I try to post them with template literals nothing happens. Nothing is logged to console. And in the network tab the data.d.results JSON is there so Im not so sure where I am going wrong
 
i tend to just learn what i need for the job now days than for the hell of it
 
@randomdude open your Netwerk inspection tool and check the POSTs, as far as I can see it fires a POST to update.php containing multipart data (the image(s)) with name image[0], image[1] and so on
so I'm expecting it to be a server side problem
 
@KevinB whats langs do you know besides cf and js?
 
some php, and enough about most others to get stuff done if needed
 
3:00 PM
How recent is your PHP knowledge?
 
i mean
i sortof maintain a wordpress site
that's up to date
but i avoid it like the plague
 
I'm just wondering how the language has progressed since I last used it...which was 10 years ago.
Dunno if you can compare.
 
i can't
 
It's supposed to be "better" now.
 
i wouldn't consider seeing how wordpress works to php being better or worse than it was
 
3:02 PM
At least so I've heard. But I also avoid it like the plague, so I've not found out how much better.
 
it is better...well it's better in terms of features
 
The bar wasn't very high to begin with.
 
the enormous amount of inconsistencies and less than no thought going into the language creation still exists
 
@JBis yeah, that's what I was mostly referring to.
It's not like we can complain much with JS and the weird history it has had.
 
JS spec is good tho. It's pretty consistent.
 
3:06 PM
Did you know that typeof null === "object" was just a bug that existed for a while and then nobody wanted to fix, since there was code written against it?
 
to me, js projects seem... prone to becoming out of date/unmaintained
 
Yeah, the new additions are quite well thought out.
 
@makadev where do i find POSTs inside network insepction?
 
@KevinB fair point. The ecosystem is bonkers.
 
@KevinB like what?
 
3:07 PM
if you use any module or tool from a 3rd party, 3 years from now it's likely to be so different that it can't simply just be upgraded
where as i have cf projects from 10 years ago still going strong, that i can hop in and modify without a second thought
 
@randomdude Firefox: developer.mozilla.org/en-US/docs/Tools/Network_Monitor/… Chrome: developers.google.com/web/tools/chrome-devtools/network/… look for either POST, XHR (since it sends per js) or just the name of the file
 
the oldest node.js project i have active at the moment requires downgrading my local node.js to work on it
it's an angular 1.15 project iirc
 
@KevinB sure, js is quickly evolving
but keep in mind, the "new age" of js began just a couple years ago
 
@makadev yes, I can see it triggers the upload.xhr but that's all. My php code used to work before I implemented this dropzone. Can we talk in pm or somewhere?
 
@JBis and yet... we still have people using IE11
 
3:11 PM
Nah, the language is fine. The tools and dependencies are just changing too fast and without much direction in many cases.
 
people t hat we can't ignore
i'd say it's still very much like it was
 
no, before you had to worry about IE11 people
now you can setup babel and have 99% of that taken care of for you
 
you still have to do it
babel doesn't polyfill things unless you specify what it should polyfill
 
@KevinB you can just put in browser settings "i want to support IE11" and it'll polyfill for you based on caniuse
 
eh, it used to
 
3:13 PM
Babel compiles syntax but doesn't polyfill. At least last time I had to tackle that. Now you have to use Core.js for polyfills + Babel.
 
the last time i used it it did not
 
babeljs.io/docs/en/babel-preset-env look at the targets option
> @babel/preset-env is a smart preset that allows you to use the latest JavaScript without needing to micromanage which syntax transforms (and optionally, browser polyfills)
 
:shrug:
that still kinda proved my point
babel itself is in fact part of my build process for that project
but... it's an incredibly old version of babel that can't simply be upgraded
 
Why?
 
because upgrading it would require rebuilding the build process
 
3:20 PM
I mean this isn't a problem unique to JS. You have people working on Java 8 and older all the time.
 
it's so vastly different today than it was for that project
 
anyway i gtg take a test, cya o/
 
Good luck!
 
@randomdude no
 
@makadev ok looks like its woking now but some functions arent. For example, in the php file I had a window location replace script which doesn't do anything now. What can cause this?
 
3:23 PM
it's ajax
what should it redirect?
 
it's one thing to upgrade my own code to be compatible with latest node.js and all the latest/greatest versions, but it's not just my code i have to worry about
 
it used to redirect me to another page. How can I do that then?
And also chrome doesn't warn if I missed a required input, it just doesn't do anything
 
probably some onsuccess hook when your uploads where completed, doing a JS side redirect
 
you can't write javascript on a .php file and return it to an ajax request and expect it to just work
well
i mean, you can expect it to work, but you'll be disappointed
 
@randomdude probably because that onclick sending bypasses submit
 
3:26 PM
@makadev sorry, I don't clearly understand this. You mean I shouldn't do JS side redirect?
 
What you are doing now ist basically just using your Form as "storage" for Files and some data, then sending it via JS without respecting submit
not sure if Dropzone can be integated better in the submit
 
Anyone want to read some batshit stuff about TypeScript and give me some feedback?
 
@phenomnomnominal is it a long read?
 
Yeah 😅
 
I can maybe do 20-30 minutes
 
3:29 PM
Oh it's definitely not 20 mins
 
Sure, hit me up, then.
 
but it should be possible to redirect them with Js, right?
 
ye
9
A: Dropzone.js - Success message after Upload

UC_SUJITHTry with this, write your success code as follows, success:function(file, response) { // Do what you want to do with your response // This return statement is necessary to remove progress bar after uploading. return file.previewElement.classList.add("...

instead of a message you can do a redirect by setting window location
 
umm, can we pass a C# variable to JS?
 
3:33 PM
yes, it's good nw. Thanks @makadev
 
The last question is the required inputs. How can I call them if they're empty?
 
@TylerH umm no.
0
Q: Placing a marker on google maps using asp.net-core razor pages

d4rk4ng31I have the following 3 pages in my project: Create.cshtml: @page @model AdminPortal.Web.Pages.Assets.CreateModel @{ ViewData["Title"] = "Create"; } <h1>Create</h1> <h4>Asset</h4> <hr /> <div class="row"> <div class="col-md-4"> <form method="post"> <div asp-validatio...

That is what I am trying to do
 
Well the linked answer is verbatim what you asked for. Not my fault if you are trying to do something different than what you asked :-)
Based on your question on main it sounds like you need to visit the "What is a NPE and how do I fix it" canonical
 
umm, yeah, sorry 'bout that😅 I guess I myself was confused
no
I know why that is NPE
I have mentioned that in the Post
 
3:38 PM
@randomdude like I said, not sure. It might be possible for Dropzone to not check for the click event of the send button but rather make the send button a submit and hook into the form's submit process
 
And if I add another onclick event to my button and check each required inputs manually with js?
 
those using browser submit stuff (like pressing enter in form, verification etc.) but stop the submit and send everything per ajax
 
if*
 
thats another option
typical js side form verification
 
cool, gonna try it. thanks for everything
 
3:40 PM
good luck^
 
const validateUsername = (value) => {
        console.log('First')
        var isValid = true;
        fetch('/api/check_username', {
            method: 'POST',
            headers: {'Content-type': 'application/json',},
            body: JSON.stringify(value)})
            .then(res => res.json()).then(res => {
                console.log(res)
                console.log(isValid)
                if(res['error']) {

                    isValid = false;
                    console.log(isValid)
                } else {
How could i get this to wait for the promise to resolve before executing the if statement (The error runs and displays the message needed through another code....
 
@phenomnomnominal "expect it iterates over the indices of a type" -> typo: "except"
 
Thanks!
 
"then that is great, the WorkerModule type acts as an identify" -> "identity"
 
3:58 PM
🤦‍♂️
 
I don't see other typos.
My feedback is that I was able to follow what you wrote. My brain is mush right now, so I consider that an accomplishment.
Also, pretty informative.
I liked the weird jumping through hoops types.
 
Nice!
Yeah it is some weird shit 😅
 
The whole "transform function types to be async between threads but only in some situations" is just the kind of thing I can see myself doing. Super niche, overall not exceptionally useful but a good source of information.
 
It's a total brainfuck
I don't even know if I explained all the weirdness
Cause a function you pass in as a parameter can be sync or async but on the other side it will definitely be sync. So you have to transform the types again on the way out to handle that!
 
4:35 PM
posted on January 26, 2021 by Ruy Adorno

Notable changes buffer: introduce Blob (James M Snell) #36811 add base64url encoding option (Filip Skokan) #36952 doc: add @iansu to collaborators (Ian Sutherland) #36951 add @RaisinTen to collaborators (Darshan Sen) #36998 add @miladfarca to collaborators (Milad Fa) #36934 fs: allow position parameter to be a BigInt in read and readSync (raisinten) #36190 http: attach request as res.req

 
 
2 hours later…
6:24 PM
@phenomnomnominal does that think support typescript worker threads?
as in, worker.ts transpiled to worker.js?
@VLAZ thanks! went well
 
 
1 hour later…
7:35 PM
|| status
 
I am currently alive!
 
|| backup
 
[Backup](undefined) Created
 
useless
 
I'm also alive. If anybody cares.
 
7:36 PM
Anyone here dead?
 
I'm also useless! 2/2 on my part
 
lol
 
Hi, how can I contact an admin guy on here. They have banned me asking questions and have not got any idea why, my questions are not even downvoted ??
 
@PaulMaximus 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.
 
@PaulMaximus Did you delete questions?
53
Q: What can I do when getting “We are no longer accepting questions/answers from this account”?

Robert HarveyDo not repost the question you were about to ask until you have READ EVERYTHING WE ARE ABOUT TO TELL YOU. While trying to ask a question, one could get: We are no longer accepting questions from this account. See the Help Center to learn more. Likewise, for answers: We are no longer acceptin...

 
7:50 PM
@JBis not sure I get you!
 
const validateUsername = (value) => {
        console.log('First')
        var isValid = true;
        fetch('/api/check_username', {
            method: 'POST',
            headers: {'Content-type': 'application/json',},
            body: JSON.stringify(value)})
            .then(res => res.json()).then(res => {
                console.log(res)
                console.log(isValid)
                if(res['error']) {

                    isValid = false;
                    console.log(isValid)
                } else {
 
const { somethingCPUIntensive } = workerRequire('./cpu-intensive');
await somethingCPUIntensive()
@phenomnomnominal can ./cpu-intensive be a typescript file?
 
yeah sure, as long as require under the hood can handle it
so running via ts-node will work
 
hey guys I am still still struggling with this How could i get this to wait for the promise to resolve before executing the if statement (The error runs and displays the message needed through another code....
 
ok can i import things?
 
7:53 PM
yep
 
in cpu-intentsive can i write import someFunc from '../someFunc'
How does that work?
 
someFunc will be run in the separate thread
it'll be a new instance of the state
 
Do I need setup the build process to support that or does it just work?
 
Depends on your TS setup
but with vanilla ts-node it should work
 
7:56 PM
usually you run tsc and then run node ./something
I'm not explaining well
 
yeah, it definitely works when compiled
as long as everything is compiled to the right place
 
Hmm. Ok. I'll take a look. I've had trouble in past with worker threads because it doesn't compile properly.
 
the typeof import('../foo') tells TS about the connection
 
sorry JBis, I didn't realise I was still in this room, yeah I have deleted questions in the past but I was still able to ask questions after that, today I log in wanting help and then clicked on ask new question and said I was banned and I have absolutely no idea why. I'm finding Stack Overflow not very newbie friendly
 
Stack Overflow isn't really newbie friendly
 
8:00 PM
yeah I have worked that out, took me ages to be able to comment so I could try to help people lol
 
I suggest you read that post and wait it out. Ban should be lifted soon. Then make sure to only ask high quality questions.
 
thanks for your advice, do you know how long the bans are in place for? I have sent an email to SO to ask why I have been banned.
 
The ban gets lifted and you can ask one Q afterwards to try and restore the ability
@PaulMaximus was 6 months last i heard
 
ouch
 
@JBis do you have any idea if its possible to do what i am trying above
essentially the throw error calls another function to display errors but if i have the entire thing as an async await then it states that the error is uncaught
 
8:02 PM
thanks guys, see you later
 
async (value) => {
[...]
await fetch([...]
 
@JBis yeah but then it runs as a uncaught error if i throw the error later within the async function and i need to error to be thrown to handle it in this component
if (requiredMissing) {
            errors = [ ...errors, `${label} is required` ];
        } else if ('function' === typeof validator) {
            try {
                validator(value);
            } catch (e) {
                errors = [ ...errors, e.message ];
            }
        }
esssentially i have two components
FormField
 
|| mdn async/await
 
and this username field
import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';

class FormField extends Component {

    state = { value: '', dirty: false, errors: [] }

    hasChanged = e => {
        e.preventDefault();
        const { label, required = false, validator = (f) => f, onStateChanged = (f) => f } = this.props;
        const value = e.target.value;
        const isEmpty = value.length === 0;
        const requiredMissing = this.state.dirty && required && isEmpty;

        let errors = [];
import React from 'react';
import PropTypes from 'prop-types';
import FormField from './Form_field';


const UsernameField = (props) => {
    const { type, validator, ...restProps} = props;


    const validateUsername = (value) => {
        console.log('First')
        var isValid = true;
        fetch('/api/check_username', {
            method: 'POST',
            headers: {'Content-type': 'application/json',},
            body: JSON.stringify(value)})
            .then(res => res.json()).then(res => {
 
8:05 PM
You have an async operation (network call).
You need to treat it as such
 
The username field runs the call and throws a new error with the message and then in the formfield it will use the error to display in the form
@JBis then how could i get it to operate in this way as its working perfectly for all the other operations but not for this
 
@Kwsswart my guess is the rest of your operations are sync
either eliminate the fetch or change your code to support an async callback
 
yeah they are thats why I am trying to think how to change it to support the async callback... maybe run the error message in the username component?
 
@PaulMaximus you can't just "wait it out"
Found that out the hard way I have been banned from posting for about two months. You have to edit your questions (not just edit them to edit them) but so they are actually of use to the community. The worst part is, that still may not do anything. 99% sure you have to have a positive question vote score, so any questions that are bad negatives will screw you
 
@bigchungus Even with a "permanent" question ban, you can still always post at least one new question every 6 months, for that very reason.
 
8:18 PM
Ah. News to me
 
The goal of the ban's implementation details is to encourage users to focus very hard on fixing problems with their question, but the exception every 6 months is an acknowledgement that sometimes momentum works against you even if you try very hard
 
8:36 PM
thank you. SO frustrates me, how can they ban it when there is no downvotes on my questions. It just doesn't make sense.
 
Well. Atleast you didn't piss someone off. God forbid you do that on this site. It doesn't take much. I had someone run through all my posts and downvote. It literally happened overnight, the odds of that being a coincidence is uncanny
 
@PaulMaximus There are other negative indicators for questions as well: whether they are closed and/or deleted.
It is all a comprehensive system where each possible state has a weight that it contributes. Upvotes, open, undeleted statuses help. Downvotes, closed, deleted statuses hurt.
@PaulMaximus SO is a repository of Q&A for future readers, so if you are asking questions that consistently get closed (e.g. they're off-topic or need more details to be answered), or if you're consistently deleting your questions, regardless of whether they get answers, then that tells the system "this person is making contributions to the site that are not beneficial at best, or harmful at worst" and thus a question ban is initiated
 
8:58 PM
@TylerH check HTML chat if you have a chance
 
9:54 PM
i have an object
const myObj = {
   a: "Hello",
   b: // i want to fetch value here using fetch api
}

how can i do that?
 
10:51 PM
const myObj = {
   a: "Hello",
   b: await fetch('url').then(resp => resp.text())
}
@JoeSaad
 

« first day (3755 days earlier)      last day (1176 days later) »