These are chat archives for FreeCodeCamp/Help

8th
Oct 2017
Moisés Man
@moigithub
Oct 08 2017 00:00
readed somewhere .. if ur component dont handle state, better use (stateless) functional component, cuz on "future" version gonna be more performant (dont remember when that article was published)
const Main = ()=> (<div>Hello</div>);
functional component dont handle state, also dont use component life cycle
Gersho
@Gersho
Oct 08 2017 00:01
well that makes sense if it's a 100% dumb component
Eric Miller
@ericmiller777
Oct 08 2017 00:04
not getting the amazing part of react
seems like a weird way of writeing javascript
Gersho
@Gersho
Oct 08 2017 00:04
it's a bit like if you combine your html and js files
Eric Miller
@ericmiller777
Oct 08 2017 00:05
"You can now inject regular JavaScript into JSX expressions! This will be extremely useful."
why
Gersho
@Gersho
Oct 08 2017 00:05
const Main = (a)=> (<div>{a}</div>);
this would be why (i'm not sure it works for this syntax, but you get the idea)
(was lazy and copy pasted Moisés's )
Moisés Man
@moigithub
Oct 08 2017 00:08
on react jsx <div> (or whatever "tags") are not really html elements.. but syntactic sugar react components (which translate to functions calls)
but easier to read/learn <div>hello</div>
than React.createElement('div', {}, "Hello")
and can get hairy if lot of nested components
Gersho
@Gersho
Oct 08 2017 00:09
it would also take ages to get anything done
the way it handles "tags" really eases the process of converting an html page to a react page
Eric Miller
@ericmiller777
Oct 08 2017 00:28
lol code acadmeny says write your code like this
const gooseImg = (
<img
 src={goose} 
/>
);
but
only works if i ype it like ```
const gooseImg = (
<img src={goose} />
);
~~~
@longnt80 thanks
CamperBot
@camperbot
Oct 08 2017 00:31
ericmiller777 sends brownie points to @longnt80 :sparkles: :thumbsup: :sparkles:
:cookie: 594 | @longnt80 |http://www.freecodecamp.com/longnt80
Eric Miller
@ericmiller777
Oct 08 2017 00:32
@heroiczero thanks
CamperBot
@camperbot
Oct 08 2017 00:32
ericmiller777 sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1839 | @heroiczero |http://www.freecodecamp.com/heroiczero
Eric Miller
@ericmiller777
Oct 08 2017 00:34
<img onClick={myFunc} />
is kinda cool
Mike
@MikeJSchorah
Oct 08 2017 01:22
@Gersho @korzo @piteto Thanks for the advice earlier, but I'm thinking of going with WooCommerce for a couple of reasons: 1. It's more popular, 2. Shopify is a DIY approach (in other words, he'll do it himself and I won't make any money, lol)
CamperBot
@camperbot
Oct 08 2017 01:22
mikejschorah sends brownie points to @gersho and @korzo and @piteto :sparkles: :thumbsup: :sparkles:
:cookie: 219 | @piteto |http://www.freecodecamp.com/piteto
:cookie: 596 | @korzo |http://www.freecodecamp.com/korzo
:cookie: 528 | @gersho |http://www.freecodecamp.com/gersho
Gersho
@Gersho
Oct 08 2017 01:24
"a patient cured is a customer lost" approach :P
reachmua
@reachmua
Oct 08 2017 01:25
Hello Folks,
I have a bit of code on the Image Abstraction API Project. And for some reason I cannot seem to get the objects expected in the Basejump.
I get an error message: "TypeError: Cannot read property 'webSearchUrl' of undefined".
Been stuck here for way too long.
// Bing API requirement
var Bing = require('node-bing-api')({ accKey: 'API-key' });

app.use(bodyParser.json());
app.use(cors());

mongoose.connect('mongodb://localhost/searchStrings');

//app.use('/static', express.static('public'));

// Search terms in the DB.
app.get('/api/searchHistory', (req, res, next) => {
    searchString.find({}, (error, data) => {
      res.json(data); 
    });
});

//Items in the DB per exercise.
app.get('/api/imagesearch/:searchString', (req, res, next) => {

    // Constructors
    var searchString = req.params;
    var skip = req.query;

    var data = new searchString({
        searchString,//: query,
        searchDate: new Date()
    });

    // Get items in the DB.
    data.save (err => {
        if (err) {
            res.send('Error saving to DB.');
         }
         // else {
        //     return res.send('Saved to DB.');
        // }
        res.json(data);
     });


    // Bing API
    Bing.images(searchString, {
        top: 5, // Pagination limit of 5 results (count).
        skip: 2 // Skip first 2 results (offset)
        },
        function(error, response, body){
            var searchData = [];
            var webSearchUrl;
            for (var i=0; i<5; i++){
                searchData.push({
                    url: body.value[i].webSearchUrl,
                });

            }
            res.json(searchData);

         });
Gersho
@Gersho
Oct 08 2017 01:26
you should try asking in the backend room
Moisés Man
@moigithub
Oct 08 2017 01:27

use console.log
only place i see.. u using webSearchUrl is

  searchData.push({
                    url: body.value[i].webSearchUrl,
                });

soo make sure ur body have a value property and inside that.. websearchurl exist

reachmua
@reachmua
Oct 08 2017 01:30
@Gersho posted there with no response.
@moigithub use console.log to test or...I am not clear as to your suggestion?
Mike
@MikeJSchorah
Oct 08 2017 01:31
@Gersho Where is all the money in software? If they can do it themselves, why do they need us? (Except for the big companies)
Gersho
@Gersho
Oct 08 2017 01:32
@MikeJSchorah as long as all parties involved know where they stand i have no problem with it :)
Gersho
@Gersho
Oct 08 2017 01:39
depends who you want to work for then i guess, also, for big companies, a lot of things have to be taken into account, they can inject a lot of money in their project, but they can also become too big to change the way they operate (but that's mostly for older companies)
like how some old systems are dependant on the few COBOL survivors
so what works for a big company isn't always the best solution for something lower scale
Ai rui 艾瑞
@aisolae
Oct 08 2017 02:20

function dot(x, y){
var x = 4;
var y = 7;
document.write(x + y);
}

function dotTwo(a, b){
var a = 99;
var b = 49;
document.write(a * b);
}

function dotAll(){
dotTwo(a, b);
dot(x, y);
}
dotAll();

`function dot(x, y){
var x = 4;
var y = 7;
document.write(x + y);
}

function dotTwo(a, b){
var a = 99;
var b = 49;
document.write(a * b);
}

function dotAll(){
dotTwo(a, b);
dot(x, y);
}
dotAll(); `

sorry for multiple posting
does anyone know what's wrong with the calling function in function
写夜子
@xieyezi
Oct 08 2017 02:27

在你的script里,添加这个方法:$(document).ready(function() {到你的script,接下来用});结束这个方法

接下来我们来学习如何写方法,方法里面的代码会被浏览器加载。

在没有document ready function以前,你的代码会在HTML没有渲染完成就执行,这样会产生bug。

<script>
$(document).ready(function() {

});

<script/>

这样写不对吗
Gersho
@Gersho
Oct 08 2017 02:27
your function takes arguments but redeclares them with a fixed value, then you call your function with parameters that are not defined @aisolae
so when you call dotTwo(a,b) a and b doesn't exist, so it can't work
Ai rui 艾瑞
@aisolae
Oct 08 2017 02:29
got it
how do i pass the value to the parameter so i can call the function in functions
Gersho
@Gersho
Oct 08 2017 02:29
@xieyezi Hello, try asking in the chinese room
https://gitter.im/FreeCodeCamp/chinese
写夜子
@xieyezi
Oct 08 2017 02:30
ok,thank you
Ai rui 艾瑞
@aisolae
Oct 08 2017 02:32

function dot(x, y){
document.write(x + y);
}
dot(4,7);

function dotTwo(a, b){

document.write(a * b);
}
dotTwo(99,60);

function dotAll(){
dotTwo(a * b);
dot(x, y);
}
dotAll();

got it
thanks @Gersho
CamperBot
@camperbot
Oct 08 2017 02:32
aisolae sends brownie points to @gersho :sparkles: :thumbsup: :sparkles:
:cookie: 530 | @gersho |http://www.freecodecamp.com/gersho
Gersho
@Gersho
Oct 08 2017 02:33
try reading about "variable scope" for more info about it
should be (a,b) not (a*b) when you call dotTwo(a,b), also you'll need to declare a,b,x,y and give them values dot dotAll to work
Ai rui 艾瑞
@aisolae
Oct 08 2017 02:38
ok
thanks
David Chen
@Obiwan777
Oct 08 2017 03:12
anyone can have a look at my code for php and html stuff?
Momozor
@momozor
Oct 08 2017 04:18
hello
David Chen
@Obiwan777
Oct 08 2017 04:38
hi everyone, what would be the reason for this error.
i have a if else statement setting up in my html page with php bracket in.
the two content, web view and mobile view.
works perfectly individually, while after putting them together, doesnt show the same result as individual.
anyone has encountered this before?
Momozor
@momozor
Oct 08 2017 05:00
Well, would you mind showing the snippet that causing this issue? Someone maybe can help you more thoroughly. @Obiwan777
Darren
@DarrenfJ
Oct 08 2017 05:23
evening fCC
@knight2 yah that link is supposed to be the actual tests they can't get running.. you can at least test each exercise using glitch to ensure you got it all working..
@GitHub-Henry thanks for the link looks kinda cool
CamperBot
@camperbot
Oct 08 2017 05:25
darrenfj sends brownie points to @github-henry :sparkles: :thumbsup: :sparkles:
:cookie: 378 | @github-henry |http://www.freecodecamp.com/github-henry
Darren
@DarrenfJ
Oct 08 2017 05:29
passing out the usual kudos and thanks to the the usual crew helping out
thanks @faraco @Gersho @ericmiller777 @khaduch @heroiczero @Marmiz @Manish-Giri
CamperBot
@camperbot
Oct 08 2017 05:30
darrenfj sends brownie points to @faraco and @gersho and @ericmiller777 and @khaduch and @heroiczero and @marmiz and @manish-giri :sparkles: :thumbsup: :sparkles:
:cookie: 313 | @ericmiller777 |http://www.freecodecamp.com/ericmiller777
:cookie: 531 | @gersho |http://www.freecodecamp.com/gersho
:star2: 1840 | @heroiczero |http://www.freecodecamp.com/heroiczero
:cookie: 383 | @faraco |http://www.freecodecamp.com/faraco
:star2: 1057 | @marmiz |http://www.freecodecamp.com/marmiz
:star2: 6632 | @manish-giri |http://www.freecodecamp.com/manish-giri
:star2: 3351 | @khaduch |http://www.freecodecamp.com/khaduch
Eric Miller
@ericmiller777
Oct 08 2017 05:31
@DarrenfJ thanks
CamperBot
@camperbot
Oct 08 2017 05:31
ericmiller777 sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles:
:star2: 2103 | @darrenfj |http://www.freecodecamp.com/darrenfj
Manish Giri
@Manish-Giri
Oct 08 2017 05:31
@DarrenfJ @heroiczero @thekholm80 @TeddyHugs ty :smile:
CamperBot
@camperbot
Oct 08 2017 05:31
manish-giri sends brownie points to @darrenfj and @heroiczero and @thekholm80 and @teddyhugs :sparkles: :thumbsup: :sparkles:
:cookie: 326 | @teddyhugs |http://www.freecodecamp.com/teddyhugs
:star2: 1841 | @heroiczero |http://www.freecodecamp.com/heroiczero
:star2: 1500 | @thekholm80 |http://www.freecodecamp.com/thekholm80
:star2: 2104 | @darrenfj |http://www.freecodecamp.com/darrenfj
Eric Miller
@ericmiller777
Oct 08 2017 05:47
lol
var k = a ? (b ? (c ? d : e) : (d ? e : f)) : f ? (g ? h : i) : j;
that would work wouldnt it :P
i know its bad just i saw it as an example
Eric Miller
@ericmiller777
Oct 08 2017 06:05

import React from 'react';
import ReactDOM from 'react-dom';

const people = ['Rowe', 'Prevost', 'Gare'];

const peopleLis = people.map(person =>
// expression goes here:

<li>{person}</li>);
);

// ReactDOM.render goes here:
ReactDOM.render(<ul>{peopleLis}</ul>, document.getElementById("app"));

how does that make sense
what is person
Manish Giri
@Manish-Giri
Oct 08 2017 06:08
@ericmiller777 dupPlayers.sort((a,b) => a[1] > b[1] ? -1 : a[1] < b[1] ? 1 : a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);
from a kata i did, just a couple of mins back
Eric Miller
@ericmiller777
Oct 08 2017 06:08
lol
congrats for solveing it
@Manish-Giri thanks
CamperBot
@camperbot
Oct 08 2017 06:08
ericmiller777 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
Manish Giri
@Manish-Giri
Oct 08 2017 06:08
to answer your question
CamperBot
@camperbot
Oct 08 2017 06:08
:star2: 6633 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Oct 08 2017 06:08
person is an array of list items
so when you put it between <ul>...</ul>
React automatically constructs the unordered list from the array items
@ericmiller777
Eric Miller
@ericmiller777
Oct 08 2017 06:10
i get it to an extent i just dont understand how it understand to do this
must be somthing to do with .map
i should read up on it
Manish Giri
@Manish-Giri
Oct 08 2017 06:12
so
const people = ['Rowe', 'Prevost', 'Gare']; <- this is the input to the .map()
for each element in people
the .map returns this
<li>Rowe</li>
<li>Prevost</li>
<li>Gare</li>
Eric Miller
@ericmiller777
Oct 08 2017 06:13
i kind of get it
person is just the name
Manish Giri
@Manish-Giri
Oct 08 2017 06:13
then it becomes an array of 3 lis
Eric Miller
@ericmiller777
Oct 08 2017 06:13
thank you
const h1 = React.createElement(
"h1",
null,
"Hello, world"
);
why does the second one need to be null?
Manish Giri
@Manish-Giri
Oct 08 2017 06:15
i don't remember what that argument stands for
but it's there in the docs
"without es6"
that section
Eric Miller
@ericmiller777
Oct 08 2017 06:18
thank you
Manish Giri
@Manish-Giri
Oct 08 2017 06:21
:+1:
Eric Miller
@ericmiller777
Oct 08 2017 06:43
i dont get why i want to use these components
but maybe i should shut up till after im done
only thing i like so far, is i can do onclick={}
Ai rui 艾瑞
@aisolae
Oct 08 2017 07:03
is it possible to give switch statement two conditions
Momozor
@momozor
Oct 08 2017 07:13
@aisolae what do you mean? You want to test two objects in the same time?
Ai rui 艾瑞
@aisolae
Oct 08 2017 07:14
for example
case (var1 && var 2){
comparing two variable
Momozor
@momozor
Oct 08 2017 07:15
This message was deleted
Momozor
@momozor
Oct 08 2017 07:23
var a = 100;
var b = NaN;
switch (true) {
  case isNaN(a) || isNaN(b):
    console.log('NaNNaN');
    break;
  case a === b:
    console.log(0);
    break;
  case a < b:
    console.log(-1);
    break;
  default:
    console.log(1);
}
Ai rui 艾瑞
@aisolae
Oct 08 2017 07:26
thanks
will check it now
Ai rui 艾瑞
@aisolae
Oct 08 2017 07:48

```var a=100;
var b =40;

switch (true){
case a > b:
document.write("a is bigger");
break;
case a < b:
document.write("b is bigger");
break;
case a === b:
document.write("a is the same as b");
break;
default:
document.write("no value is greater")
break;
}

thanks @faraco
CamperBot
@camperbot
Oct 08 2017 07:49
aisolae sends brownie points to @faraco :sparkles: :thumbsup: :sparkles:
:cookie: 384 | @faraco |http://www.freecodecamp.com/faraco
Momozor
@momozor
Oct 08 2017 07:53
I think it is better to use the regular if else conditionals. It is much readable if the conditionals are not tedious and repetitive.
if (a > b){
     document.write("a is bigger");
 }

else if (a == b) {
    document.write("a is equal to b");
}
unless you are doing the freecodecamp challenge which need you to use switch statement of course.
heroiczero
@heroiczero
Oct 08 2017 08:10
@DarrenfJ @faraco @Gersho @ericmiller777 @khaduch @Marmiz @Manish-Giri @piteto @korzo @longnt80 @sjames1958gm TY for Helping everyDay :)
CamperBot
@camperbot
Oct 08 2017 08:10
heroiczero sends brownie points to @darrenfj and @faraco and @gersho and @ericmiller777 and @khaduch and @marmiz and @manish-giri and @piteto and @korzo and @longnt80 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 314 | @ericmiller777 |http://www.freecodecamp.com/ericmiller777
:cookie: 385 | @faraco |http://www.freecodecamp.com/faraco
:cookie: 598 | @korzo |http://www.freecodecamp.com/korzo
:star2: 1058 | @marmiz |http://www.freecodecamp.com/marmiz
:cookie: 532 | @gersho |http://www.freecodecamp.com/gersho
:star2: 2105 | @darrenfj |http://www.freecodecamp.com/darrenfj
:cookie: 595 | @longnt80 |http://www.freecodecamp.com/longnt80
:star2: 3352 | @khaduch |http://www.freecodecamp.com/khaduch
:star2: 6635 | @manish-giri |http://www.freecodecamp.com/manish-giri
:cookie: 220 | @piteto |http://www.freecodecamp.com/piteto
:star2: 8528 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Eric Miller
@ericmiller777
Oct 08 2017 08:11
@heroiczero thanks
Pethaf
@Pethaf
Oct 08 2017 09:31
Hey, could someone help me with the SASS challenges?
I am doing the "Sass: Store Data with Sass Variables" challenge, I have changed the css to
$text-color: red; .header{ text-align: center; } .blog-post,h2 { color: $text-color; } what am I doing wrong?
Momozor
@momozor
Oct 08 2017 09:44
thanks @heroiczero
CamperBot
@camperbot
Oct 08 2017 09:44
faraco sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1843 | @heroiczero |http://www.freecodecamp.com/heroiczero
SL0TR
@SL0TR
Oct 08 2017 11:51
can anyone help me with the transform property "scale-up" blurring the text issue?
Stephen James
@sjames1958gm
Oct 08 2017 12:15
@SL0TR Can you describe the issue more?
@Pethaf freeCodeCamp/freeCodeCamp#12699
@Pethaf The SASS challenges may not be working.
Alexander Køpke
@alexanderkopke
Oct 08 2017 12:23
@Pethaf your code works
Pethaf
@Pethaf
Oct 08 2017 12:43
I think the best approach is to copy over the assignments to coepen.
aRtoo
@artoodeeto
Oct 08 2017 15:52
hey guys on my calculator challenge when i click the button and push the value itll just replace the not add in my array.
heres the pen.https://codepen.io/artoo/pen/gGvvER thanks in advanced
Thanh Son Nguyen
@nguyen-thanhson
Oct 08 2017 16:58
@artoodeeto line 98. You have two equal signs in a variable declaration. Also each time a number is pressed, you are declaring a new empty digitsArray
I suggest you declare the digitsArray outside of the holder function, push the number (a, not res) into the array
then each time you need to reset the display field, empty the digitsArray
then it should work
oh and get rid of line 98 altogether
Justin25
@Justin25
Oct 08 2017 17:27
Does anyone have experience using express routes with mongoDB?
Dhaval
@Dhavalc2012
Oct 08 2017 17:37
hi @Manish-Giri
nice to see you after a long time lol
Stephen James
@sjames1958gm
Oct 08 2017 19:31
@artoodeeto You create an empty array each time
kiran JD
@kiranjd
Oct 08 2017 20:47
$(document).ready(function(){
 $.getJSON("https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=", function(a) {
  $("body").append(a[0].content + "<p>&mdash; " + a[0].title + "</p>")
});
});
Help. I'm not able to print the data in the body section of html
gishy1
@gishy1
Oct 08 2017 20:49
hello world !!!
need help
image.png
kiran JD
@kiranjd
Oct 08 2017 20:50
@gishy1 Read the corresponding links they recommended
gishy1
@gishy1
Oct 08 2017 20:51
@kiranjd yes but im stuck because reverseString is not a variable
so how do i convert it to an array
kiran JD
@kiranjd
Oct 08 2017 20:51
Yes it's not. It's a function
The correct function call is reverse()
gishy1
@gishy1
Oct 08 2017 20:52
so i reverse the whole function?
i thought reverse was for an array
kiran JD
@kiranjd
Oct 08 2017 20:53
You cannot use it on a function. You can use use it only on array of strings
var split line is useless
return str.reverse(); return reversed string
gishy1
@gishy1
Oct 08 2017 20:55
@kiranjd i was thinking turn into a variable and then split
kiran JD
@kiranjd
Oct 08 2017 20:55
before that you have to split the array using str.split()
gishy1
@gishy1
Oct 08 2017 20:56
@kiranjd how do i access the string though ?
kiran JD
@kiranjd
Oct 08 2017 20:56
inside the reverseString function
gishy1
@gishy1
Oct 08 2017 21:01
@kiranjd so i access the string through the function
kiran JD
@kiranjd
Oct 08 2017 21:02
No. You access it inside the function
Replace the return str; line with return str.split();
You will get the idea
gishy1
@gishy1
Oct 08 2017 21:05
@kiranjd ya that gives me hello
@kiranjd do i turn into an array and then reverse?
kiran JD
@kiranjd
Oct 08 2017 21:06
okay use return str.split('');
yes
gishy1
@gishy1
Oct 08 2017 21:07
@kiranjd ok so now it turns them into strings
kiran JD
@kiranjd
Oct 08 2017 21:08
now str.splt('').reverse();
gishy1
@gishy1
Oct 08 2017 21:08
@kiranjd s i actually tried that before lool and it didnt work out
kiran JD
@kiranjd
Oct 08 2017 21:09
now?
gishy1
@gishy1
Oct 08 2017 21:09
@kiranjd ya i added .join
and it still has the ,s
so im assuming I have to somehow remove the ,s
@kiranjd got it !!!
needed to join with the "" to make a string thanks Bro!!
gishy1
@gishy1
Oct 08 2017 21:16
@kiranjd so let me get this right you whenever you split or reverse or join you are accessing the (parameter)?
kiran JD
@kiranjd
Oct 08 2017 21:16
yes!
gishy1
@gishy1
Oct 08 2017 21:17
@kiranjd finally im learning something !!
kiran JD
@kiranjd
Oct 08 2017 21:17
You will get better the more you code
see ya!
gishy1
@gishy1
Oct 08 2017 21:20
@kiranjd hopefully!!!
StrategyIsKey23
@23beyblade
Oct 08 2017 23:13
hey anyone here know what the form attribut "form-control" does ? thanks
knight2
@knight2
Oct 08 2017 23:24
working on node and express
Let’s serve our first string! In Express, routes takes the following structure: app.METHOD(PATH, HANDLER). METHOD is an http method in lowercase. PATH is a relative path on the server (it can be a string, or even a regular expression). HANDLER is a function that Express calls when the route is matched.

Handlers take the form function(req, res) {...}, where req is the request object, and res is the response object. For example, the handler

function(req, res) {
res.send('Response String');
}
will serve the string 'Response String'.

Use the app.get() method to serve the string Hello Express, to GET requests matching the / root path. Be sure that your code works by looking at the logs, then see the results in your browser, clicking the button ‘Show Live’ in the Glitch UI.
i wrote
app.get("/root", function(req, res){
  res.send('Hello Express')
})
but apparently that is wrong, what is correct?
the instructions for this section are very unclear.
knight2
@knight2
Oct 08 2017 23:30
NVM root is '/' obviously.
next challenge
We can respond with a file using the method res.sendFile(path).

You can put it inside the app.get('/', ...) route handler. Behind the scenes this method will set the appropriate headers to instruct your browser on how to handle the file you want to send, according to its type. Then it will read and send the file. This method needs an absolute file path. We recommend you to use the Node global variable __dirname to calculate the path.

e.g. absolutePath = __dirname + relativePath/file.ext.

The file to send is /views/index.html. Try to ‘Show Live’ your app, you should see a big HTML heading (and a form that we will use later…), with no style applied.

Note: You can edit the solution of the previous challenge, or create a new one. If you create a new solution, keep in mind that Express evaluates the routes from top to bottom. It executes the handler for the first match. You have to comment out the preceding solution, or the server will keep responding with a string.
var absolutePath = "dirname" + "/views/index/html"
app.get("/", function(req, res){
res.send("
dirname/views/index.html")
})
is incorrect
var absolutePath = "__dirname" + "/views/index/html"
app.get("/", function(req, res){
res.sendFile("/views/index/html")
})
sendfile obviously, but using __dirname prefix doesn't work, nor does just/views/ work
"path must be absolute or specify root to res.sendFile
when using " res.sendFile("__dirname/views/index/html")
"
knight2
@knight2
Oct 08 2017 23:43
now it works
When I googled a DIFFERENT website's tutorial on rendering webpages with node.js
app.get("/", function(req, res){
res.sendFile(path.join(__dirname+'/views/index.html'))
})
and you need to add var path = require("path")
The really messed up thing is, I see bugs reported for beta 8 months ago, still existing...
20 extra minutes spent on something extremely trivial because FCC's instructions are incomplete and unclear. When someone else's instructions make it very clear.
knight2
@knight2
Oct 08 2017 23:51
i'm just going to assume the rest of the challenges in Apis And Microservices are bugged and the instructions are incomplete, and to look up OTHER PEOPLE's tutorials instead.
'If don’t know what a middleware is, don’t worry. " POLISHED. Not even spell checked. Much less code debugged.
knight2
@knight2
Oct 08 2017 23:57

one last comment: Onto next challenge. I am amazed by the level of INCOMPLETE the ENTIRE section is for beta. And yes, 'beta is beta', but they've been encouraging people to use it since February, and have been anticipating switching over any time.

Apparently people don't realize that you are probably ruining the experience of other's. If someone has to spend all their frustration trying to get something to work because of some error in your website, they aren't going to have that tolerance to spend actually programming once they figure out what the silly error is (which is your fault)

Yeah, it is free. But make a good platform. The amount of errors is incredible.