These are chat archives for FreeCodeCamp/Help

25th
May 2018
Michael S
@Ohshi60
May 25 2018 00:28
can anyone explain what babel does? :D
Kyle Holm
@thekholm80
May 25 2018 00:29
it makes new js features run in old js environments
so cutting edge can run on internet explorer lol
Michael S
@Ohshi60
May 25 2018 00:30
oh, thanks. Why would i use it in development though? :D
Kyle Holm
@thekholm80
May 25 2018 00:31
i use it for a few things. Node doesn't support import and export so sometimes i'll use babel to enable those features
also, babel can take JSX and turn it into HTML, so it's used with React
Michael S
@Ohshi60
May 25 2018 00:32
I just want to create a view using Vue.js for my REST backend but im hella confused. And they say Vue is the easy one :(
Kyle Holm
@thekholm80
May 25 2018 00:32
i'm sure i've only used it for a fraction of what it can do
Bjorn van de Peut
@bjorno43
May 25 2018 00:32
Ugh. Glad I got some decent internet security installed. Almost got hit by a JS bitcoin miner on a normally very trustworthy website
Kyle Holm
@thekholm80
May 25 2018 00:32
@bjorno43 :wave: hiya
Bjorn van de Peut
@bjorno43
May 25 2018 00:32
@thekholm80 Yo :wave:
@thekholm80 Seen my latest "fun" project messing around with canvas?
Kyle Holm
@thekholm80
May 25 2018 00:33
i have not
Bjorn van de Peut
@bjorno43
May 25 2018 00:34
@thekholm80 https://codepen.io/bjorno43/pen/bMyppJ Simulation of object movement (drag the rectangle)
In reality, you can't move objects in canvas. Canvas doesn't retain objects in memory after they're drawn. So instead, the canvas is emptied on each mouse move event and re-drawn using the mouse coordinates
Kyle Holm
@thekholm80
May 25 2018 00:39
that's pretty slick
i love canvas
Bjorn van de Peut
@bjorno43
May 25 2018 00:42
Ghehe ye it was fun messing around with that. At first no matter where you clicked inside the canvas, the rect was redrawn in the middle of the cursor pointer. Then I improved the code so it checked if the mouse was actually on the existing rect before doing a re-drawn. Still the rect would just "jump" to the middle of the mouse pointer. Then, after a few trial and errors, I managed to use the mouse pointers initial click position as the offset for a re-drawn, simulating a full object movement :smile:
Kyle Holm
@thekholm80
May 25 2018 00:43
very cool
Bjorn van de Peut
@bjorno43
May 25 2018 00:47
@thekholm80 Thanks. Ye I thought so as well. Actually made me realise that this would be the ground principle of creating a 2D game engine for canvas
CamperBot
@camperbot
May 25 2018 00:47
bjorno43 sends brownie points to @thekholm80 :sparkles: :thumbsup: :sparkles:
:star2: 1794 | @thekholm80 |http://www.freecodecamp.org/thekholm80
Michael S
@Ohshi60
May 25 2018 01:13
in a fullstack web application is it common practice to separate the back end and front end entirely? Ĺike in different folders? So i have a backend folder and a client folder?
Bjorn van de Peut
@bjorno43
May 25 2018 01:16
@Ohshi60 The way I normally work is by creating a backend class that loads front end pages inside a seperate folder
I can't say if it's common practice or not. But if you look at most CMS's, all front-end templates are inside a seperate folder. So for clarity, I'd say it is
Michael S
@Ohshi60
May 25 2018 01:20
so i create my viewapplication and access my backend endpoints using AJAX requests using a full url reference as a request?
Bjorn van de Peut
@bjorno43
May 25 2018 02:04
@Ohshi60 I thought you ment project documents wise. No, you never use the entire URL. The reason for this is simple: If you ever change your domain, you shouldn't need to edit your project's source codes just to make them work again. Another reason might be that you make your project open source, in which case others downloading your project shouldn't have to remove your domain from the source either.
Michael S
@Ohshi60
May 25 2018 02:14
then how do i expose the backend routes to my front-end, if that makes sense. or are you talking about storing the url as a variable? :)
Kyle Holm
@thekholm80
May 25 2018 02:16
if your back end is serving the front end, they both have the same location. when you do it locally it's usually http://localhost:whateverPortYouRunOn so from the front end you can use relative paths like /api and it will actually be going to http://localhost:whateverPortYouRunOn/api
Bjorn van de Peut
@bjorno43
May 25 2018 02:17
Just use the file structure on the server. Say for example you have your AJAX request in index.html, and the backend script it calls is inside /accounts/register.php. Then just call ./accounts/register.php as URL in your index.html file. It doesn't need to know the url itself. Just the path to where it can find the backand script
Perhaps a more simple way to understand it: If no actual domain is given, it'll automaticly use the domain that was used to visit the site
Michael S
@Ohshi60
May 25 2018 02:21
okay so i can just use the relative /api/ endpoint as url
trying to get a Vue frontend up for a random project to impress a potential employer :D - proven to be harder than i thought, but i guess i needed to learn the same thoughtprocess if i wanted to learn react
Bjorn van de Peut
@bjorno43
May 25 2018 02:23
Yup. Though I believe if you put a / at the beginning, you'll need to put a dot there as well. So ./api/ or just api/
In unix format ./ stands for "this folder" while ../ stands for "previous folder"
Michael S
@Ohshi60
May 25 2018 02:24
i know, ive been living in a command-line for 3 years now :)
Bjorn van de Peut
@bjorno43
May 25 2018 02:25
Cool^^
Kyle Holm
@thekholm80
May 25 2018 02:25
i'd think the biggest difference between learning vue and react right now is you can find 10,000,000 how-tos for react
or maybe i just see them everywhere because that's what i look for lol
Michael S
@Ohshi60
May 25 2018 02:26
hmm, does that mean i have to start BOTH my backend and my front end seperately?
Bjorn van de Peut
@bjorno43
May 25 2018 02:28
What do you mean with "start them seperately"? As in, develop each of them seperately?
Michael S
@Ohshi60
May 25 2018 02:29
@thekholm80 both are scary. Ive finally reached a decent comfortzone with Node and express and mongoose and was stuck a week between what framework to try to learn. Then i saw a local company was running Vue and decided it was fate lol :D But all that babel webpack shit scares me!!
Kyle Holm
@thekholm80
May 25 2018 02:29
every framework has its own set of challenges
Michael S
@Ohshi60
May 25 2018 02:29
@bjorno43 currently i start my backend using node (server.js)
Kyle Holm
@thekholm80
May 25 2018 02:29
i've seen some really great stuff made with vue
Michael S
@Ohshi60
May 25 2018 02:30
and i just installed a vue-frontend that i use npm run to start
@thekholm80 ive seen some really beautiful react sites as well :D
Bjorn van de Peut
@bjorno43
May 25 2018 02:31
@Ohshi60 Oh. I've only got a very small bit of experience with Node. But I think firing up server.js automaticly fires up Node's HTTP server so your front end would work as well
Claudio Restifo
@Marmiz
May 25 2018 02:32
@Ohshi60 if you feel overwhelmed by the boilerplate: nuxt is a great tool imho
Kyle Holm
@thekholm80
May 25 2018 02:33
@Marmiz is a React ninja
Bjorn van de Peut
@bjorno43
May 25 2018 02:33
Honestly, I love what Node can do. I just hate the way it works. In my 16 years as a dev I simply got way too used to Apache(2)
Claudio Restifo
@Marmiz
May 25 2018 02:34
@thekholm80 :shipit:
Michael S
@Ohshi60
May 25 2018 02:34
@bjorno43 i remember setting up apache could be a bit of a pain
node is just SOOOO easy...i guess its express but still :D
Kyle Holm
@thekholm80
May 25 2018 02:34
I <3 node/express
Claudio Restifo
@Marmiz
May 25 2018 02:34

node is just SOOOO easy

sweet innocence

Bjorn van de Peut
@bjorno43
May 25 2018 02:34
Sure it can be. Definitely! I'm not saying it's better than node. Just saying I'm used to it, haha
Michael S
@Ohshi60
May 25 2018 02:35
Hey since the world is 80% wordpress you can always use apache or am i wrong? :D
Bjorn van de Peut
@bjorno43
May 25 2018 02:36
I just wish Node was available like PHP is. That you can use your own webserver and simply serve the files to be parsed to Node
I mean, technically it's possible using the Proxy directive in Apache. But that's more of a workaround, lol
Michael S
@Ohshi60
May 25 2018 02:39
i was gonna say you might find a library in the NPM repository that does that. Which is another great thing about node. Npm reminds me of python-pip
Bjorn van de Peut
@bjorno43
May 25 2018 02:39
It's like running node on a different port than 80 and then using apache to redirect node projects towards that port, ghehe
Michael S
@Ohshi60
May 25 2018 02:39
oh the other way around
Kyle Holm
@thekholm80
May 25 2018 02:39
i feel like that's exactly how heroku works
i thought they ran an apache server to handle all the traffic to my node environment?
and the server would tell the dynamo when to spin up/sleep and all that
Bjorn van de Peut
@bjorno43
May 25 2018 02:41
Ye. But the Proxy module can be extremely abused. You could for example redirect a normal websocket to a "websocket secure" fooling browsers like Firefox that a secure websocket is used while it isn't. Simply because Firefox doesn't allow normal websockets on https enabled websites
Nazar
@IsaakNazar
May 25 2018 03:20
@sjames1958gm thx Stephen
CamperBot
@camperbot
May 25 2018 03:20
isaaknazar sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9255 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Mandeep Sharma
@mandeephub
May 25 2018 12:16
Hello to all
@all
Someone told me that i should learn OOPS concepts before learning any framework it will help me learning that any framework easily in future is it true......
Dionisis Terzios
@ElJimador
May 25 2018 12:17
Hello, I am stuck at the twitch api project because it displays the streamers with null even if the streamer is currently online.
https://codepen.io/Terzio/pen/zjPBoq?editors=0001 Please advice me.
HamdanKhan
@HamdanKhan
May 25 2018 12:17
@mandeephub you can learn OOPS along side your learning, there is no set in stone guide lines
They are concepts which will help you understand why your code structure is written in a certain way but initially for somepeople these concepts presented does not click.
HamdanKhan
@HamdanKhan
May 25 2018 12:23
tradtional javascript is not pure oo, I gues this guy will explain it.
Screen Shot 2018-05-25 at 5.27.50 PM.png
HamdanKhan
@HamdanKhan
May 25 2018 12:29
@ElJimador stream is null
var stream = result0.stream;
console.log(result0);
it will show u comple json object
Dionisis Terzios
@ElJimador
May 25 2018 12:35
@HamdanKhan I did that. But why did you write it too me because the problem is still there. If you look, I wrote if "blah blah" echo status offline or online. Some channels are online but it keeps saying they're not.
Stephen James
@sjames1958gm
May 25 2018 12:40
@ElJimador Because when your inner $.ajax runs - the for loop has completed (async) and
var sApi = "https://wind-bow.glitch.me/twitch-api/streams/" + streamers[i]; this will be set to the last streamer and so you are only querying the last streamer
multiple times
@ElJimador Open your browser devtools and the network tab and you will see multiple requests for noobs2ninjas stream URL
Dionisis Terzios
@ElJimador
May 25 2018 12:46
@sjames1958gm Thanks. I didn't know this trick. How do I give cookies?
CamperBot
@camperbot
May 25 2018 12:46
eljimador sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 9256 | @sjames1958gm |http://www.freecodecamp.org/sjames1958gm
Dionisis Terzios
@ElJimador
May 25 2018 12:46
Nevemind.
Stephen James
@sjames1958gm
May 25 2018 12:46
@ElJimador :+1:
HamdanKhan
@HamdanKhan
May 25 2018 12:46
CamperBot did that :)
Dionisis Terzios
@ElJimador
May 25 2018 12:46
@sjames1958gm I'll need more help from you. Where can I find you if I'll need your help?
Stephen James
@sjames1958gm
May 25 2018 12:47
@ElJimador I am usually around this page or help javascript, here is a page that might help
http://stackoverflow.com/questions/750486/javascript-closure-inside-loops-simple-practical-example
Norvin Burrus
@ndburrus
May 25 2018 16:57
@Ohshi60 ...a few project structure ideas. :sparkles:
Norvin Burrus
@ndburrus
May 25 2018 17:35
@mandeephub ...oop viewpoints/information.: :sparkles: