This question concerns the Firestore database, but, more generally, it concerns making async requests in parallel. Simply put, I wish to update multiple Firestore documents as quickly and efficiently as possible by mapping over an array of their document IDs. the .set() method is async (returning a promise) a…
Tag: javascript
Group results of multiple POST API calls
I use the below script to loop through the input (skipping first one) to post some data to my API. Result How can I capture the combined response of both calls into a variable I can use later on in my script? something like var allNum = res.result.number[0]? This is what I want -> Var allTens = “002,…
Show an element if date is before or after another date using Vue js
I’m using vue to dynamically show elements (called boxes) on the page, but I need to display an element based on if it’s start date is before or after today+1 week. So if the box.start_date is before one week from today, then show it, else hide it. I’m not sure how I can do this in vue ie. I…
How can I create a hook that reacts to an event to load more data?
I am trying to create a functionality where if a user clicks on a LOAD MORE button, it returns more data. I already have some code done but every time I click on the LOAD MORE button, it removes the first 12 items and sets the new 12 items, but I don’t want that, I want to keep the 12
Plotly.js 3D scatter plot is just black
This is something that has recently broken. Previously, I was getting normal plots when running the exact same code however now the plot is just a black screen. (Pictured Below) I am not sure what changed. I tried reverting to an older version of plotly but that did not fix it. I do not even know where to beg…
Stop awaiting remaining promises if one returns sentinel value
I have a function validateTables() that validates that data exists in several tables using a call (per table) to an async helper function queryTable() that queries the api. To pass validation, data must exist in every table. If a table is empty, the helper function will return false. I currently have the set …
Initialise an object with array properties
How can I initialise an object in JavaScript, the properties of which would be arrays? I want to have an object of this format: My usecase is the following: – When a property does not exist, create this property which should be an array and add a number. – When a property exists already, push the …
Changing an object value from a Class
I have a js file handling my css where I am trying to change the value of an object, but the value stays the same. I assume the “this.opacity” is only returning a reference and not modifying the actual object and I am unsure of how to make this object mutable. How would I go about changing this va…
Moment object won’t increment by days when cloned and used with DateTimePicker
I have the following code: I am using the following React component to change the date: The info for the component is here: https://material-ui-pickers.dev/ When I change the date the date is not incremented by the number of days listed in the first block of code (I explain more in the comments) Thank you! An…
ES6 Classes: Bind “this” to nested functions
I have multiple nested functions in a ES6 Class. Now I wonder how I can easily bind this of the class instance to all the subfunctions. I know of… …but it feels like an awkward solution for multiple nested functions. Does anyone know of a more elegant solution? Answer You can use arrow functions. …