These are chat archives for FreeCodeCamp/Help

21st
Mar 2019
WONG KWONG CHIU
@keith-wong
Mar 21 00:44
hi there
is there anyone know how to find an online entry job in programming to make money
Philip Durbin
@pdurbin
Mar 21 00:51
We hired someone through Rent A Coder once but that was maybe 12 years ago. It was renamed or aquired or something and is mentioned at https://en.wikipedia.org/wiki/VWorker
Kaylee
@kaymonlee
Mar 21 01:02
how do you link an external style sheet to codepen? I don't understand
Momozor
@momozor
Mar 21 01:33
@cmccormack yes, but the json returned by the server if error
you know like, {error: 'this error is..'}
Momozor
@momozor
Mar 21 01:43
@cmccormack For example, I cannot even console.log(response.json()) if server returns error.
            return fetch(url, {
                method: 'POST',
                body: formData

            }).then(response=>{
                if (response.ok) {
                    return response.json()
                } else {
                    console.log(response.json())
                    throw new Error('invalid URL')
                }
            })
it seems like I'm trying to access a promise object?
app.js:23 Uncaught (in promise) SyntaxError: Unexpected token B in JSON at position 4
    at fetch.then.response
Christopher McCormack
@cmccormack
Mar 21 01:51
@momozor the error is because your response is not a json object. try using response.text() instead
Momozor
@momozor
Mar 21 02:19
@cmccormack Promise {<resolved>: "400 Bad Request"}
I got that with console.log(response.text())
but how do I get the json?
kinopotato
@kinopotato
Mar 21 05:35
can I ask a question here that is more related to coding productivity rather than actual coding
kibablu
@kibablu
Mar 21 06:55
how do you link an external style sheet to codepen? I don't understand...<link rel="stylesheet" href="yourfile.css">
hensn5250
@hensn5250
Mar 21 07:21
@kibablu Settings button ---> CSS tab ---> Add External Stylesheets/Pens
EvilJinC
@WJingC
Mar 21 07:48
hello world
kibablu
@kibablu
Mar 21 08:32
@hensn5250 Thank you
kinopotato
@kinopotato
Mar 21 08:34

hello, can someone help me with request (nodejs) syntax? github api is making me use something called curl, I don't know how to fit that with my code.

const request = require("request");

const getUserData = (user) => {
  request(user, (error, response, body) => {
    console.log(body);
  })
};

getUserData("https://api.github.com/users/octocat"); //Request forbidden by administrative rules....

It wants me to type something like this

curl -iH 'User-Agent: ' https://api.github.com/meta

but I don't know where to put it

dyon gerwen
@fullstackinprogress_gitlab
Mar 21 13:34
c an someone write this in ejs6 code instead of jquery so i can understand it
    jQuery.ajax({
        url: this.opt.sBaseURL + '/XMLHTTP/selectTab',
        data: submitData,
        dataType: 'xml',
        success: jQuery.proxy(this.handleInjectTransactions, this)
    }).done(console.log("helloooo",this));
alpox
@alpox
Mar 21 14:52
@fullstackinprogress_gitlab there is no exact equivalent as this would give you xml wrapped in a jquery object as a result in this.handleInjectTransactions which is not available without jquery. The equivalent with just getting xml text instead would be something like:
const queryString = '?' + Object.entries(submitData).map(([key, value]) =>`${key}=${value}`).join('&');

fetch(this.opt.sBaseUrl + '/XMLHTTP/selectTab' + queryString)
  .then(response => response.text())
  .then(this.handleInjectTransactions.bind(this))
  .then(result => console.log("helloooo", this));
kinopotato
@kinopotato
Mar 21 15:44
function getUserData(user) {
  gitFunc(user).then((response) => {
    const data = response.data;
    return `${data.login} ${data.url}`;
  }).catch((error) => console.log(error.message));
}

console.log(getUserData("kinopotato"));
hello, how do I get the return data.login data.url part to show on console without using console.log inside the function?
alpox
@alpox
Mar 21 16:14
@kinopotato .then(console.log)
Christopher McCormack
@cmccormack
Mar 21 16:28
@kinopotato you can pass a callback function that you invoke from within the response
or just log it in the response