I’m writing a react component which requires TWO or MORE API calls inside componentDidMount as below. The 2 API calls will update 2 different states and thus two different child components will be re-rendered. However, I believe what I wrote is not the best approach, since potential failure of one API w…
Tag: javascript
discord.js upper case & lower case embed message not working
So I wrote a “test” command and wanted to make it in a way where when people type -test, the upper cases and lower cases don’t matter. The command should work with -test, -Test, -TEST, etc. Currently, the command only works with -test and no upper cases. I also tried changing it from toLower…
Why is this first line not a function? [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 2 y…
React Error: “SharedArrayBuffer is not defined” in Firefox
I have a React app, created with ‘create-react-app’ (I also use jsdom NPM package), and for some reason, the application throws an error on load Only in Firefox (works fine in Chrome & Edge). Here is the error: After some Googling I found: “To enable SharedArrayBuffer in Firefox, go to a…
i want to count each word in a string but skip words that have special chars or numbers in them. ex (“j9[”, “h5”) will be skipped
Each word is a sequence of letters, (‘a- A-Z), that may contain one or more hyphens and may end in a punctuation mark period ), comma ().question mark (?), or exclamation point (1). Words will be …
Express.Router, body-parser and post request body
I am trying to seperate my routes using express.Router and testing some post requests with Postman. Doing a post request to /test without using router body-parser works fine and i can see the body. Doing the exact same request to /posts which is using Router gives me undefined for the body. I call body-parser…
How to get the filename from the full path and store in an object property in Javascript?
My initial problem was to store only the filename from the full path on an object and I did find the answers to that online but I had problem storing the same in a property of an object. Here is a piece of code that I have written. Hopefully my problem would be clear. This whole code is inside a
Combining some() and startsWith() javascript
I have an array with strings: const fruits = [‘Apple’, ‘Banana’, ‘Orange’] I am trying to write a function that returns true or false depending on if a string starts with any string in the array, which would be true for example ‘Applepie’ or ‘Bananabread&#…
Communicate from JS to Shiny in a module
I want to set an input element from the JS side and react upon it from the Shiny side. Shiny.setInputValue(<name>, <val>) does that for me. However, I want to listen to that element from within a module, which makes that I have to namespace <name>, which makes it a bit difficult. I found the…
Webpack ES6 modules multiple class app organization
I’m building an app with webpack for the first time and i’m trying to wrap my head around organizing class files. I’m having trouble getting the code to work. I’m still new to ES6 and such, so my code below is probably very wrong but i’m not sure its my approach/concept or its my…