Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Feb 01 00:27
    @bjorno43 banned @Ndoua
  • Jan 07 03:10
    @bjorno43 banned @doctor-sam
  • Aug 17 2019 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 2019 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 2019 17:13
    @mstellaluna banned @cmal
  • Jan 08 2019 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
intoverq
@selimerunkut
Hello, could someone point me to the right direction why my grid system is overlapping in this modal dialog:
https://jsfiddle.net/intoverq/1gmb3kf0/54/
intoverq
@selimerunkut
somehow adding bootstrap.min.css to to vue.js transition modal the modal does not show up anymore, would appreciate if someone point me to the error : https://codepen.io/intoverq/pen/WNNOaZN
Cliff Galas
@Sn0wm8n
How do I upload my completed challenge to github It's been 4 years or more since I was last doing the challenges
Does it have to get approved and then it is uploaded
by freecodecamp.com ?
Cliff Galas
@Sn0wm8n
Anyone there?
Tom
@moT01
@Sn0wm8n a challenge or project?
If it's just one of the challenges, you would probably have to download it from the challenge page first
then upload it to one of your github repos
Cliff Galas
@Sn0wm8n
project
Tom
@moT01
easiest way if you don't have git installed or know how to use it - would be to just go to your github profile - create a new repo and go to it - click the upload files button - and just drag and drop
Cliff Galas
@Sn0wm8n
Tom what if those projects are in codepen
Tom
@moT01
Not sure if there's a way to export code from codepen - it doesn't look like it
you can do the same as I said above, but instead of clicking upload files, click create new file - give it a name and copy/paste the code in there
then click commit at the bottom
make sure the files have the right names and extensions
siliconchild
@siliconchild
can someone help me with an async function that has a loop and filter
Kaz Baig
@kbaig
sup
siliconchild
@siliconchild
const fetchAllProducts = async () => {
    const productsList = [];
    const categories = await GetActiveCategories();
    const categoriesIdArray = categories.map(category => category.CategoryId);
    categoriesIdArray.forEach(async categoryID => {
        const response = await getSearchResults(" ", categoryID);
        productsList.push(...response);
    });
    return productsList;
 }

const hotDeals = async () => {
    const products = await fetchAllProducts();
    return products.forEach(product => product.MRP/product.SellingPrice > .8)
}
Brad
@bradtaniguchi
what behavior do you seek: make the calls and don't wait for anything, or wait for all calls and do something, or make each call waiting for the previous
Looks like you want the 2nd one, where you make all the calls and wait for all of them to be done. Id's use Promise.all
and the .map, without async/await
return Promise.all(categoriesIdArray.map(categoryID => getSearchResults(' ', categoryID)));
@siliconchild
siliconchild
@siliconchild
@bradtaniguchi thank a lot, let me try that
Brad
@bradtaniguchi
Just a word of warning, I don't advise this approach for large lists. Not because the code is wrong, its that if your on the client-side making X number of calls things can slow dramatically
siliconchild
@siliconchild
@bradtaniguchi i understand that, i am thinking to run this a cloud function on netlify that i can call
i dont have access to the server api
to create new apis there
Brad
@bradtaniguchi
Ah, if your calling an API it isn't as bad, but still non-optimal if the list is large. If the api your interfacing with is designed for it tho, then it shouldn't matter too much
siliconchild
@siliconchild
@bradtaniguchi yes this is hacky solution, since there is no api to fetch deals, i am writing this intermediary api to create one. is there a better solution if i can't create an api in the original server
@bradtaniguchi is the issue with this, creating too many reads of the database?
Brad
@bradtaniguchi
Well for each request you make you go through the "entire flow" of a request in the api, so the webserver is called, logic is checked, potentially multiple database calls are called (for security+your data) and thats for each call
siliconchild
@siliconchild
@bradtaniguchi so this would bog down the server considerably?
the list has currently less than 1000 items
Brad
@bradtaniguchi
Whoa, it could get up to 1k calls? :O
Its impact on the server depends on how its implemented
if its a nodejs server, and lets say there is 0 security, your still looking at 1k individual database calls, and 1k router hits all at the same time. Heck that could bring up DDOS protection with some web servers (idk if that applies here tho)
siliconchild
@siliconchild
@bradtaniguchi i don't much about server side, but when this logic is written on the server side, woudn't the all the data needs to read to filter and create this api?
so that would create a similar load on the database right?
Brad
@bradtaniguchi
Not sure what you mean by "woudn't the all the data needs to read to filter and create this api?"
Kaz Baig
@kbaig
What brad said, you're going to be waiting for each call to end before moving on to the next one in the array unless you use Promise.all
siliconchild
@siliconchild
so promise.all runs in parallel ?
Brad
@bradtaniguchi
yes
Kaz Baig
@kbaig
yep
siliconchild
@siliconchild
const fetchAllProducts = async () => {
    const categories = await GetActiveCategories();
    const categoriesIdArray = categories.map(category => category.CategoryId);
    return Promise.all(categoriesIdArray.map(categoryID => getSearchResults(' ', categoryID)));
 }
is this enough, this is still returning a promise
Brad
@bradtaniguchi
Lets say you had access to the DB yourself, you'd make 1 call/request to it with a query, and get 1 response back with all your data. Its a lot less processing to handle the network transfers at each level
Your in an async function, it always is a promise
siliconchild
@siliconchild
ok so i just need to write another async function to await fetchAllProducts?
Brad
@bradtaniguchi
what? I thought thats what you already had?