These are chat archives for FreeCodeCamp/HelpJavaScript

10th
Nov 2017
Diego Mayer
@Chrono79
Nov 10 2017 00:00
Try using: http://www.pythontutor.com/javascript.html#mode=edit
Nvm, it won't work either in there
You got a kind of infinite (it's not infinite because of the maximun stack call size exceeded error) recursion loop
iso
@iso1048
Nov 10 2017 00:05
@Chrono79 ok. yeah I am having trouble with this challenge - it is the hardest one yet for me. Ill give it another go. Thanks man!
CamperBot
@camperbot
Nov 10 2017 00:05
gothamknight sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4599 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Nov 10 2017 00:06
@gothamknight No problem, try googling for Heap Algorithm
iso
@iso1048
Nov 10 2017 00:06
Will do. Thanks again @Chrono79
CamperBot
@camperbot
Nov 10 2017 00:06
gothamknight sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
api offline
iso
@iso1048
Nov 10 2017 00:11
@Chrono79 you still on bro?
Diego Mayer
@Chrono79
Nov 10 2017 00:14
yes
iso
@iso1048
Nov 10 2017 00:18
@Chrono79 The linkedin chrome extension links with one's linkedin account to alert them when they have a notification in their account. I was wondering what kind of things I would have to know in order to make a similar chrome extension.
Diego Mayer
@Chrono79
Nov 10 2017 00:19
Never did a Chrome extension, can't tell
FlashHero
@FlashHero
Nov 10 2017 00:52
If i have ABC and I pick first character as A then I have two spots I can put A at BC -> ABC, BAC, BCA CB -> ACB, CAB, CBA can someone give me a example of how would ABCD follow this rule please i'm stuck at this no repeats please algorithm
Staller_y
@stellaryy
Nov 10 2017 01:03
Hello,I hava a question
could you help me

function lookUp(firstName, prop){
// 请把你的代码写在这条注释以下
for(var i = 0; i<contacts.length;i++){

  if(contacts[i].firstName != firstName){//不存在firstName

  return "No such contact";
  }else if(contacts[i].hasOwnProperty(prop)){//存在firstName&&存在对应的属性

  return contacts[i][prop];
  }else{

  return "No such property";
  }

}

// 请把你的代码写在这条注释以上
}

why don't show it
Christopher Brown
@ChrisBrownie55
Nov 10 2017 01:07
@FlashHero it’s the same idea, take a letter move it into the positions after it one for each combo, and move to another letter and do the same, abcd bacd bcad bcda acbd acdb abdc
I think that works, not sure
Moisés Man
@moigithub
Nov 10 2017 01:07
if u have ["A","B","C"]
and u looking for "B"
since "A" != "B" what ur code will do ?? @stellaryy
Staller_y
@stellaryy
Nov 10 2017 01:08
it show "No such contact"
oh
i konw
Moisés Man
@moigithub
Nov 10 2017 01:09
yep.. it will end/exit the function (cuz return)
without checking all rest of the array
Staller_y
@stellaryy
Nov 10 2017 01:09
thank you
i see it
Staller_y
@stellaryy
Nov 10 2017 01:20
but it also can't show it

function lookUp(firstName, prop){
// 请把你的代码写在这条注释以下
for(var i = 0; i<contacts.length;i++){

  if(contacts[i].firstName == firstName){//不存在firstName
   if(contacts[i].hasOwnProperty(prop)){

return contacts[i].prop;
}else{

return "No such property";
}

}else{

return 'No such contact';
}

}
// 请把你的代码写在这条注释以上
}

Christopher Brown
@ChrisBrownie55
Nov 10 2017 01:21
@FlashHero
```

@FlashHero

// let n be your letter position
for (i = n; i < string.length; ++i) {
    returnArray.push(moveLetter(n, i))
}

repeat for each letter and that should give you all combos

git00000
@git00000
Nov 10 2017 02:10
hello world
how to ingrate Vuejs with python Flask framework?
FlashHero
@FlashHero
Nov 10 2017 02:26
@ChrisBrownie55 thanks man
CamperBot
@camperbot
Nov 10 2017 02:26
flashhero sends brownie points to @chrisbrownie55 :sparkles: :thumbsup: :sparkles:
:cookie: 267 | @chrisbrownie55 |http://www.freecodecamp.com/chrisbrownie55
Roger Futrell
@rogfut
Nov 10 2017 02:26
Hello. im struggling with evaluating a function inside an if condition. is something like this possible? if(myFunction(input) == false ) { //do something }
FlashHero
@FlashHero
Nov 10 2017 02:30
@korzo and @Blauelf thanks for yesterday's help on no repeats please algorithm
CamperBot
@camperbot
Nov 10 2017 02:30
flashhero sends brownie points to @korzo and @blauelf :sparkles: :thumbsup: :sparkles:
:cookie: 760 | @korzo |http://www.freecodecamp.com/korzo
:star2: 4649 | @blauelf |http://www.freecodecamp.com/blauelf
FlashHero
@FlashHero
Nov 10 2017 02:31
@rogfut can you elaborate on what exactly you're having problems with
Roger Futrell
@rogfut
Nov 10 2017 02:33
I think I got it, i wasmissing an input for my function :( on to the next problem
FlashHero
@FlashHero
Nov 10 2017 02:34
ok
Giordi JoJo
@giordifungula
Nov 10 2017 08:17

I am struggling with this
if(myObj.hasOwnProperty(checkProp) === true){
return myObj.checkProp;
} else {
return "Not Found";
}

return ;
}

// Test your code by modifying these values
checkObj("pet");

Markus Kiili
@Masd925
Nov 10 2017 08:24
@giordifungula .checkProp looks for property key "checkProp", and not the key stored in parameter checkProp.
===true is also redundant there.
Last return; is also redundant.
web2-4
@dormitory2017
Nov 10 2017 08:32
翻转字符串
Giordi JoJo
@giordifungula
Nov 10 2017 08:34
@Masd925 okay cool thank so should i use "checkProp" instead of the key stored in parameter something similar to this ?
CamperBot
@camperbot
Nov 10 2017 08:34
giordifungula sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4568 | @masd925 |http://www.freecodecamp.com/masd925
Giordi JoJo
@giordifungula
Nov 10 2017 08:34
function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty("checkProp")){
return myObj.checkProp;
} else {
return "Not Found";
}
Markus Kiili
@Masd925
Nov 10 2017 08:35
@giordifungula No, you need to use the bracket notation that evaluates the expression inside the brackets to a string. Dot notation just reads the string after the dot and uses it. So return myObj[checkProp]; <- checkProp is evaluated to whatever string was passed on the function call.
So if you know the property key, you can use the dot notation. If you need to evaluate the key, use the bracket notation.
Tiago Correia
@tiagocorreiaalmeida
Nov 10 2017 09:09
image.png
anyone?
script worked well at home commited it and today downlaoded the file to start on it ffrom aqnother place and well
alpox
@alpox
Nov 10 2017 09:17
@tiagocorreiaalmeida Best take a look at the debug log which is provided
Claudio Restifo
@Marmiz
Nov 10 2017 09:19
@tiagocorreiaalmeida have you installed the packages?
Tiago Correia
@tiagocorreiaalmeida
Nov 10 2017 09:21
its related to the node-sass package saw alot of pages about people on github tryingt o help anyway havent found a solution yet :D
```
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\tiagocorreia.BTL\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'start' ]
2 info using npm@5.5.1
3 info using node@v8.6.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle trading-book-club@1.0.0~prestart: trading-book-club@1.0.0
6 info lifecycle trading-book-club@1.0.0~start: trading-book-club@1.0.0
7 verbose lifecycle trading-book-club@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle trading-book-club@1.0.0~start: PATH: C:\Users\tiagocorreia.BTL\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin;C:\book-trading-club-master\book-trading-club-master\node_modules\.bin;%SystemRoot%\system32\WindowsPowerShell\v1.0\;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\nodejs\;C:\Users\tiagocorreia.BTL\AppData\Local\atom\bin;C:\Users\tiagocorreia.BTL\AppData\Roaming\npm;C:\Program Files\Microsoft VS Code\bin
9 verbose lifecycle trading-book-club@1.0.0~start: CWD: C:\book-trading-club-master\book-trading-club-master
10 silly lifecycle trading-book-club@1.0.0~start: Args: [ '/d /s /c', 'npm-run-all --parallel watch:sass devserver' ]
11 silly lifecycle trading-book-club@1.0.0~start: Returned: code: 1  signal: null
12 info lifecycle trading-book-club@1.0.0~start: Failed to exec start script
13 verbose stack Error: trading-book-club@1.0.0 start: `npm-run-all --parallel watch:sass devserver`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Users\tiagocorreia.BTL\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:280:16)
13 verbose stack     at emitTwo (events.js:125:13)
13 verbose stack     at EventEmitter.emit (events.js:213:7)
13 verbose stack     at ChildProcess.<anonymous> (C:\Users\tiagocorreia.BTL\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:125:13)
13 verbose stack     at ChildProcess.emit (events.js:213:7)
13 verbose stack     at maybeClose (internal/child_process.js:927:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
14 verbose pkgid trading-book-club@1.0.0
15 verbose cwd C:\book-trading-club-master\book-trading-club-master
16 verbose Windows_NT 6.1.7601
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\tiagocorreia.BTL\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "start"
18 verbose node v8.6.0
19 verbose npm  v5.5.1
20 error code ELIFECYCLE
21 error errno 1
22 error trading-book-club@1.0.0 start: `npm-run-all --parallel watch:sass devserver`
22 error Exit status 1
23 error Failed at the trading-book-club@1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
```
alpox
@alpox
Nov 10 2017 09:23
@tiagocorreiaalmeida Ah wait i think i know what it could be. What machine are you working on? (OS)?
Tiago Correia
@tiagocorreiaalmeida
Nov 10 2017 09:25
win7 64
lets hope you do @alpox almost pulling my hairs off :D
at home I use windows 8 64 bits but dont think its anything related to do and its even the same architecture
alpox
@alpox
Nov 10 2017 09:27
@tiagocorreiaalmeida Hmm okay on windows it must be some other problem
I believe something blocks the devserver from watching the sass files
Tiago Correia
@tiagocorreiaalmeida
Nov 10 2017 09:28
image.png
alpox
@alpox
Nov 10 2017 09:29
@tiagocorreiaalmeida Also, did you check if not some watch/devserver process is already running somewhere in the system?
Tiago Correia
@tiagocorreiaalmeida
Nov 10 2017 09:30
was runing command by command so the command to watch changes on the sass files si working the only problem is really with the live-server
    "devserver": "live-server",
wait im missing the global
oh boy
alpox
@alpox
Nov 10 2017 09:32
global? Got some environment variable which is not set? :D
Tiago Correia
@tiagocorreiaalmeida
Nov 10 2017 09:32
the one just above :D
forgot it was a global one
alpox
@alpox
Nov 10 2017 09:32
Aaha :D
Tiago Correia
@tiagocorreiaalmeida
Nov 10 2017 09:33
on point time to move on :D thanks @alpox
CamperBot
@camperbot
Nov 10 2017 09:33
tiagocorreiaalmeida sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1450 | @alpox |http://www.freecodecamp.com/alpox
alpox
@alpox
Nov 10 2017 09:33
@tiagocorreiaalmeida I again was only duck duck :D
Tiago Correia
@tiagocorreiaalmeida
Nov 10 2017 09:34
ahahaha the day just started and allready learned something :D
alpox
@alpox
Nov 10 2017 09:34
xD
Daniel Romero
@Ranacode
Nov 10 2017 10:04
Hey guys, I have an issue fetchin data with React native
It gives me an undefined object but when I try my api via postman it works good
This is my fetch call
export const fetchMeetups = () => {
    fetch('http://10.0.2.2:8000/api/meetups', { method: 'GET' })
        .then(res => res.json())
        .catch(error => {
            throw new Error(error)
        })
}
And this is my component
import { fetchMeetups } from './constants/api'


export default class App extends Component {
  static defaultProps = {
    fetchMeetups
  }

  state = {
    loading: false,
    meetups: []
  }

  async componentDidMount() {
    this.setState({ loading: true })
    const data = await this.props.fetchMeetups();
    setTimeout(() => this.setState({ loading: false, meetups: data.meetups }), 2000)
  }

  render() {
    return (
      <View style={styles.container}>
        {this.state.loading && <ActivityIndicator size="large" />}
        <Text>
          MEETUP BUDDY
          {this.state.meetups.map((meetup, index) => {
            <Text key={index}>{meetup.title}</Text>
          })}
        </Text>
      </View>
    );
  }
}
abraham anak agung
@padunk
Nov 10 2017 10:11
@Ranacode have you try console.log(data)? what is the output?
Claudio Restifo
@Marmiz
Nov 10 2017 10:18

@Ranacode not 100% sure but doesn't response.json() return a promise as well?
In that case you need to:

const data = await this.props.fetchMeetups().then(response => console.log(response))

Not sure tho

alpox
@alpox
Nov 10 2017 10:20
@Ranacode You forgot toreturn your promise --> return fetch('http://.......
@Marmiz response.json() does indeed return a promise. That doesn't hurt him here though

@Marmiz await can and has to be used with a promise so

const data = await this.props.fetchMeetups();
console.log(data);

is fine

abraham anak agung
@padunk
Nov 10 2017 10:28
@alpox how to use async and await?
aRtoo
@artoodeeto
Nov 10 2017 10:36
hey guys how would i know if theres a click event that is happening
??
because if theres a click event i want to disable something
Claudio Restifo
@Marmiz
Nov 10 2017 10:38
@alpox I'm such addicted to axios that I barely remember fetch :)
Anyway good eyes :+1:
On that fetch cont I assumed it was a () => fetch()... or better, didn't pay attention to the wrapping {}
Markus Kiili
@Masd925
Nov 10 2017 10:46
@artoodeeto Do you wan't to detect a click on the page or detect a click event handler firing?
Daniel Romero
@Ranacode
Nov 10 2017 11:05
LOL, thanks @alpox that was stupid for my part
CamperBot
@camperbot
Nov 10 2017 11:05
ranacode sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star2: 1451 | @alpox |http://www.freecodecamp.com/alpox
Staller_y
@stellaryy
Nov 10 2017 11:06
i need help!please
function palindrome(str) {
// 请把你的代码写在这里
var a = str.toLowerCase().replace(/[[]\s\?.!-,:\'\"]+/g,'').split("").reverse().join("");
var b = str.toLowerCase().replace(/[[]\s\?.!-,:
\'\"]+/g,'').split("").join("");
if(a==b){
return true;
}return false;
}
palindrome("not a palindrome");
palindrome("0_0 (: /-\ :) 0-0") 应该返回 true.
it always return false
i don't kown where i wrong
Markus Kiili
@Masd925
Nov 10 2017 11:08
@stellaryy Most likely a problem with the regexp. Check if it really removes non-alphanumerics.
Stephen James
@sjames1958gm
Nov 10 2017 11:14
@stellaryy You can use devtools console to test if your regex is correct, or a regex testing site
alpox
@alpox
Nov 10 2017 11:19
@padunk Best would be to read up on it :-)
@Ranacode np :-)
git00000
@git00000
Nov 10 2017 11:20
hi
@Masd925 hello
Markus Kiili
@Masd925
Nov 10 2017 11:20
@git00000 Hi.
git00000
@git00000
Nov 10 2017 11:20
?can't figure out how to make them work together
@Masd925 How to integrate flask and vuejs
Blauelf
@Blauelf
Nov 10 2017 11:21

@stellaryy Putting your code between lines of triple backticks to show it more correctly here on chat (```):

                function palindrome(str) {
        // 请把你的代码写在这里
            var a = str.toLowerCase().replace(/[\[\]\s\?\.!-,:_\'\"]+/g,'').split("").reverse().join("");
            var b = str.toLowerCase().replace(/[\[\]\s\?\.!-,:_\'\"]+/g,'').split("").join("");
            if(a==b){
                return true;
            }return false;
        }
        palindrome("not a palindrome");

You don't seem to remove backslashes (\). Also, your - in the character set defines a range, the part !-, matches all characters from ! to ,, that's all of !"#$%&'()*+,, so you don't remove -. Your RegExp code is overly complex, you could define much simpler regular expressions for that, as the only thing not to remove are alphanumeric characters.

Apart from that, .split("").join("") doesn't do anything valuable.

Also, you could compute your a from b.split("").reverse().join(""), and would have that nasty regular expression only once, and have to change it in only one place.

Markus Kiili
@Masd925
Nov 10 2017 11:21
@git00000 I have done some python, but don't know an answer to that.
git00000
@git00000
Nov 10 2017 11:23
can someone give me a reference or something that illustrate how make it
I am struggling how to use component with my flask app
Blauelf
@Blauelf
Nov 10 2017 11:27
I thought vuejs were client-side and flask server-side? Does use of vuejs depend on the kind of server?
git00000
@git00000
Nov 10 2017 11:29
I build a vue project with webpack, but don't know how to merge it with my Flask app
Blauelf
@Blauelf
Nov 10 2017 11:29
I've used only flask so far, that's why I might miss something about Vue.js.
git00000
@git00000
Nov 10 2017 11:30
how to use vuejs components with flask
can I use import statement in my javascript file? to import the components and make it run ?
Blauelf
@Blauelf
Nov 10 2017 11:32
I have no idea what "vuejs components" are, but Flask in my understanding is some web server running Python scripts, like Node/Express is running JavaScript. Just that Flask also has Jinja templating language.
Blauelf
@Blauelf
Nov 10 2017 11:38
The JavaScript part should be somewhat independent of whether you use Flask, as Flask will just serve your files and render your templates.
git00000
@git00000
Nov 10 2017 11:42
SyntaxError: import declarations may only appear at top level of a module
?
Blauelf
@Blauelf
Nov 10 2017 11:49
Haven't used vue.js or webpack, I assume one would serve the transpiled and bundled script file as a static file?
bahaa aldin
@bahaa-al-deen
Nov 10 2017 12:41
how to find index of a value in an irregular multidimensional array ?
mustimuu
@mustimuu
Nov 10 2017 12:41
guys
I have got a question. Maybe its the wrong place to ask
I have a book i want to put on my website with HTML, not a PDF. Is there any tutorials?
Or guides?
Giordi JoJo
@giordifungula
Nov 10 2017 12:42
lol its not the wrong place bro there is a comuunity ready to help lol
mustimuu
@mustimuu
Nov 10 2017 12:42
Thank you so much.
@giordifungula thanks
CamperBot
@camperbot
Nov 10 2017 12:42
mustimuu sends brownie points to @giordifungula :sparkles: :thumbsup: :sparkles:
:cookie: 196 | @giordifungula |http://www.freecodecamp.com/giordifungula
Giordi JoJo
@giordifungula
Nov 10 2017 12:44
what do you mean by book like ? pages ? 1- whatever number of pages you have ?
mustimuu
@mustimuu
Nov 10 2017 12:44
100 pages
Giordi JoJo
@giordifungula
Nov 10 2017 12:44
sounds interesting have not heard of that myself I would like to know how to do that also did you try you tube ?
mustimuu
@mustimuu
Nov 10 2017 12:44
My teacher told me it is possible, instead of PDF you can code it in with HTML. So it becomes more UX friendly
Giordi JoJo
@giordifungula
Nov 10 2017 12:46
wow i will check around and see if i can find that Sounds cool though im sure someone here will know bro thanks
Kelechi Chinaka
@ke1echi
Nov 10 2017 12:49
@Blauelf any idea of a good C resource to learn the language?
heroiczero
@heroiczero
Nov 10 2017 12:50
@BahaaZidan did you try using indexOfand for loops?
bahaa aldin
@bahaa-al-deen
Nov 10 2017 12:51
the thing is , i'm using recursion because i don't know the structure of the input array @heroiczero
heroiczero
@heroiczero
Nov 10 2017 12:52
@BahaaZidan so you are given a random input of a irregular multi-dimensional array?
bahaa aldin
@bahaa-al-deen
Nov 10 2017 12:54
@heroiczero yes
i managed to find the element i want using recursion but in order to do any operation on it i have to know index
heroiczero
@heroiczero
Nov 10 2017 12:57
@BahaaZidan so you know the element but you want to do a operation on it and return the array? (Just trying to figure out what you are trying to do)
bahaa aldin
@bahaa-al-deen
Nov 10 2017 12:57
@heroiczero exactly
to give you some context, i'm trying to achieve a commenting system like the one in Disqus
where you can reply to any comment (recursively)
Kelechi Chinaka
@ke1echi
Nov 10 2017 13:08
i'll check it out @heroiczero
Stephen James
@sjames1958gm
Nov 10 2017 14:23
@BahaaZidan Give some sample input and the sample output that you want - might make it clearer.
bahaa aldin
@bahaa-al-deen
Nov 10 2017 14:29
"comments": [
        {
            "updatedAt": "2017-11-10T12:31:48.183Z",
            "createdAt": "2017-11-10T12:21:58.687Z",
            "content": "6546546546454",
            "_id": "5a0599e6ce79cf14c030a33d",
            "votes": 0,
            "replies": [
                {
                    "updatedAt": "2017-11-10T12:31:48.183Z",
                    "createdAt": "2017-11-10T12:31:48.183Z",
                    "content": "yarab",
                    "votes": 0,
                    "replies": [],
                    "_id": "5a059c34eada18197c41e027"
                }
            ]
        }
    ],
that's a simple input
Christopher Brown
@ChrisBrownie55
Nov 10 2017 14:29
@BahaaZidan if you’re trying to find the index of a comment you’d have to recursively enter each comment within a comment and check the value.
bahaa aldin
@bahaa-al-deen
Nov 10 2017 14:29
bear in mind that every replies array can hold replies which in turn hold replies and so on
@ChrisBrownie55 can you clarify
i couldn't find the index with recursion just the value
because in recursion you lose track of the parent array in every new invoke
Stephen James
@sjames1958gm
Nov 10 2017 14:31
What is the input that you are searching for and the output expected? You want the index into comments ?
bahaa aldin
@bahaa-al-deen
Nov 10 2017 14:31
i'm searching for the index of a reply with the id = 'bla bla bla'
as i said i managed to find the reply it self
not it's index
Stephen James
@sjames1958gm
Nov 10 2017 14:33
@BahaaZidan Do you want the comment index? So if you have two comments and the reply is somewhere in the second comment
the result is 1?
So you want the index of the reply in the replies array it is found in?
bahaa aldin
@bahaa-al-deen
Nov 10 2017 14:34
no i want all the way
Stephen James
@sjames1958gm
Nov 10 2017 14:34
So an array of indexes?
bahaa aldin
@bahaa-al-deen
Nov 10 2017 14:34
like if it's deep 5 levels
yes
Christopher Brown
@ChrisBrownie55
Nov 10 2017 14:34
@BahaaZidan you should return the index at the end of each recursion in an array and the one that gets it back can use spread expansion to put it in a new array with that index
bahaa aldin
@bahaa-al-deen
Nov 10 2017 14:34
will be something like [0,5,3,2,1]
Christopher Brown
@ChrisBrownie55
Nov 10 2017 14:34
And by the end it should have each index
bahaa aldin
@bahaa-al-deen
Nov 10 2017 14:35
@ChrisBrownie55 can you show me a small example ?
Christopher Brown
@ChrisBrownie55
Nov 10 2017 14:40
@BahaaZidan can’t right now, got school, I’ll try when I can
bahaa aldin
@bahaa-al-deen
Nov 10 2017 14:40
alright man :+1:
Blauelf
@Blauelf
Nov 10 2017 14:50
@BahaaZidan You could have a recursive function like
const findPath = (list, value, key = "_id", children = "replies") => {
  for (let index = 0; index < list.length; index++) {
    if (list[index][key] === value) {
      return [index];
    }
    if (Array.isArray(list[index][children])) {
      let res = findPath(list[index][children], value, key, children);
      if (res) {
        return [index, ...res];
      }
    }
  }
};

findPath(comments, "bla bla bla")
I guess that's about what @ChrisBrownie55 meant.
Stephen James
@sjames1958gm
Nov 10 2017 14:54
@BahaaZidan using reduce: but the same idea
https://jsbin.com/jufiqu/edit?html,js,console
Blauelf
@Blauelf
Nov 10 2017 15:00
I wish reduce had a way to skip the rest of the array.
Kelechi Chinaka
@ke1echi
Nov 10 2017 15:03
someone told me today that it is only logical to do C before any other. what do you think ? @Blauelf @sjames1958gm
Stephen James
@sjames1958gm
Nov 10 2017 15:04
@kelechy Seems like a silly comment. C is still used in a lot of Linux and IoT as well. Depends on what you need.
Kelechi Chinaka
@ke1echi
Nov 10 2017 15:06
so would you say learn C first is good for a begineer into programming @sjames1958gm
Stephen James
@sjames1958gm
Nov 10 2017 15:07
@kelechy Maybe I misread that. Did it mean that you should do C first?
Kelechi Chinaka
@ke1echi
Nov 10 2017 15:07
yes @sjames1958gm
Stephen James
@sjames1958gm
Nov 10 2017 15:09
@kelechy Oh. then I did misread that. Not sure I would agree with that either.
With all the online tools, you can choose many languages.
Python, javascript, etc.
With tools like pythontutor you can approach a lot of languages
IMO
Kelechi Chinaka
@ke1echi
Nov 10 2017 15:11
since most high level language implemented C under the hood, i think having a grasp of it is nt a bad idea, after all its a small language(they said) @sjames1958gm
Blauelf
@Blauelf
Nov 10 2017 15:12
@kelechy Of all C-like languages, I happened to learn Java first, back in the 90s, later learnt some JavaScript (browser APIs of Netscape vs. IE was too much pain) and C (still nice on microcontrollers). The syntax of those C-like languages is similar, and I learnt pointer arithmetics and inline assembler before, in Turbo Pascal. So... what are you supposed to learn from C first?
Diego Mayer
@Chrono79
Nov 10 2017 15:14
You should learn your languages in alphabetic order, Assembler, Basic, C, Delphi, Elixir, F and so on
Only one for letter: https://en.wikipedia.org/wiki/List_of_programming_languages
Stephen James
@sjames1958gm
Nov 10 2017 15:14
@Chrono79 lol
@kelechy well I am not sure what implemented C under the hood means, C++ has its roots in C, but other languages are only C-like in syntax
Blauelf
@Blauelf
Nov 10 2017 15:15
I started with QBASIC. Is that B as in Basic, or Q as in QBASIC? (and yes, you could use it to call the mouse driver interrupt 51/0x33)
Kelechi Chinaka
@ke1echi
Nov 10 2017 15:15
memory management, pointers and the likes.. so i can implement them well in my choice language(js) @Blauelf
:smile: @Chrono79
yea i think python tutor is cool @sjames1958gm
Blauelf
@Blauelf
Nov 10 2017 15:21
@kelechy When you use a language with garbage collection, you might have to adjust to the garbage collection used. So all this malloc/free of C won't help you much on JavaScript. Object references are similar to pointers, but not exactly. JavaScript does not allow for 64-bit integers, and bitwise operations are really slow (float64->int32-(operation)->int32->float64). So the similarities are limited.
Kelechi Chinaka
@ke1echi
Nov 10 2017 15:22
hmm.. thats true @Blauelf
Blauelf
@Blauelf
Nov 10 2017 15:29
I sometimes think learning a low-level language first teaches you to not use uninitialised variables, as they lead to crashes and frequent reboots (on MS-DOS). On JavaScript, you have silent fails, a non-existent property evaluates to undefined, and your programme works just to throw a completely unrelated error much later. This makes debugging a pain.
Kelechi Chinaka
@ke1echi
Nov 10 2017 15:33
yea @Blauelf
i want to dive in C so i can learn memory management, pointers etc.. i suck at those kind of katas at CW @Blauelf
Blauelf
@Blauelf
Nov 10 2017 15:35
Haven't even tried such katas. Do you have an example?
Blauelf
@Blauelf
Nov 10 2017 15:59
Oh, yeah. That one's weird.
Christopher Brown
@ChrisBrownie55
Nov 10 2017 16:04
@kelechy I would suggest learning C++ (the newest version) because it helps you get a good grasp of a lot of concepts in programming while teaching you a very useful language and it’s got lot more to it than other more modern languages; however if you’re going into something like web development then it is of no use to you really, but if you’re trying to learn programming in general then C++ is a good place to start
Isaiah Trembley
@IsaiahCT
Nov 10 2017 16:04
boi
c++ was complex AF
or atleast learning it as a beginner
C# was good though
and java
Christopher Brown
@ChrisBrownie55
Nov 10 2017 16:09
It’s complicated but that’s what’s good about it, it makes you take the time to learn it boi. It’s hard but it really sticks with you once you get it down.
Once you have a hang of C++ most stuff isn’t as daunting, or at least that’s the way it was for me, I mean I learned a bunch more languages too but C++ is a good starting place if you really want to get yourself dirty. Granted it doesn’t really matter what order you learn in but I liked understanding C++ early on
Assembly was hard though
Even after C and C++
Kelechi Chinaka
@ke1echi
Nov 10 2017 16:21
life of a programmer is weird @Blauelf :smile:
Tiago Correia
@tiagocorreiaalmeida
Nov 10 2017 16:23
tell me if im wrong but.. I was looking into the trading book apps that exists and all them have a trade button but you dont give nothing in return when youy trade, isnt that confusing and agaisnt the principle of it?:D
Blauelf
@Blauelf
Nov 10 2017 16:37
You probably get some point value to your account, which you can use to receive something?
Jason Luboff
@JLuboff
Nov 10 2017 16:47
@tiagocorreiaalmeida The trading app in itself is kind of lame lol. But ultimately, no theres no true trading involved. I made it so you the person requesting a trade is required to have a game available to trade thus the other person can look and see if the person requesting the trade has something they want
@tiagocorreiaalmeida https://gametrader.glitch.me
Tiago Correia
@tiagocorreiaalmeida
Nov 10 2017 17:10
im gonna do it something like that I will let the user make a book request trade and then the user itself offer a book for the one he wants and the user on the other side see it and accepts or not its a valid idea I think
Daniel Romero
@Ranacode
Nov 10 2017 17:10
I have a weird issue
The images that I fetch from random user api are blurry :worried: XD
Jason Luboff
@JLuboff
Nov 10 2017 17:14
@tiagocorreiaalmeida Ya thats basically how I did it
@Ranacode Are you sure you're grabbing the full size image and not the thumbnail?
Blauelf
@Blauelf
Nov 10 2017 17:23
@kelechy @Chrono79 The C puzzle pointer monster is driving me crazy. I think I got the first few types right, but now for the f function pointer. Or pointer to function? Or pointer to pointer to function? Maybe 2D array of function, yes, that must be right. Or something like that.
May Kittens Devour Your Soul
@diomed
Nov 10 2017 17:27
does any1 here know angular? I need some assistance over smth
Diego Mayer
@Chrono79
Nov 10 2017 17:31
@Blauelf You'll solve it eventually ;) :+1:
May Kittens Devour Your Soul
@diomed
Nov 10 2017 17:35
@Chrono79 help me with angular, maybe?
Mark White
@s3venvials
Nov 10 2017 17:37
Hello guys and gals I am needing some assistance. I am trying to replicate the retrieving from the mongoDB. I can add to the mongoDB and see it but when I put in my foreach loop in the main .ejs file to render it I get a reference error not defined. Anyone able to assist?
Blauelf
@Blauelf
Nov 10 2017 17:38
@Chrono79 I found a signature that would compile. I don't think it's the right one, as the code crashes, and we have no options for debugging.
May Kittens Devour Your Soul
@diomed
Nov 10 2017 17:39
@Blauelf angular?
Jason Luboff
@JLuboff
Nov 10 2017 17:40
@s3venvials How are you accessing your database? You can't access it from the frontend.. you need the backend to send the data
Mark White
@s3venvials
Nov 10 2017 17:41
I am accessing it from my app.js file. Im using node.js with express and mongoose and a few other dependencies
mongoose.connect("mongodb://localhost/qaah");
Jason Luboff
@JLuboff
Nov 10 2017 17:41
@s3venvials Ok, so you
Adel
@AdelMahjoub
Nov 10 2017 17:42
@s3venvials can you post the request handler and the code section from the ejs file
Jason Luboff
@JLuboff
Nov 10 2017 17:42
're sending the data to be rendered then correct?
Adel
@AdelMahjoub
Nov 10 2017 17:42
maybe rendering before the query complete or the query return null
Mark White
@s3venvials
Nov 10 2017 17:42
I believe so, sorry still new to this.
Adel
@AdelMahjoub
Nov 10 2017 17:43
or the ejs try to access a not referenced variable
Mark White
@s3venvials
Nov 10 2017 17:43
So I have a js file in modals and I require it in my app.js file with Application = require("./models/application"), along with others but thats the one with the Schema

var mongoose = require("mongoose");

//SCHEMA SETUP
var applicationSchema = new mongoose.Schema({
name: String,
url: String
});

module.exports = mongoose.model("Application", applicationSchema);

then to retreive:
app.get("/qaah", function(req, res){
// get all applications from DB
Application.find({}, function(err, allApplications){
if(err){
console.log(err);
} else {
res.render("index",{ applications: allApplications });
}
});
});

For loop in the .ejs file to render the data

<% applications.forEach(function(application){ %>
<h4> <%= application.name %> </h4>
<a href="<%= application.url %>">Test</a>
<% }); %>

sorry
wrong one

not sure if its needed but I add to the DB with

app.post("/qaah", function(req,res){
var name = req.body.name;
var url = req.body.url;
var newApplication = {name: name, url: url};
// Create a new application and save to DB
Application.create(newApplication, function(err, newlyCreated){
if(err){
console.log(err);
} else {
console.log(newlyCreated);
res.redirect("/qaah");
}
});
});

I have another app with almost the same set up and it works fine but I cant seem to figure this one out

I get this error

ReferenceError: C:\Users\1211551\Desktop\node_js\qaah\views\index.ejs:537
535|

536| 

537| <% applications.forEach(function(application){ %>

538|           <h4> <%= application.name %> </h4>

539|           <a href="<%= application.url %>">Test</a>

540|       <% }); %>
I dont get how im not defining applications
Adel
@AdelMahjoub
Nov 10 2017 17:48
@s3venvials you are sending applications with an s
Mark White
@s3venvials
Nov 10 2017 17:48
I tried it with out same deal
Adel
@AdelMahjoub
Nov 10 2017 17:48
@s3venvials get rid of the s first
@s3venvials res.render("index",{ applications: allApplications }); but in ejs : application
Mark White
@s3venvials
Nov 10 2017 17:49
alright let me try getting red of the "s"
Adel
@AdelMahjoub
Nov 10 2017 17:49
@s3venvials then check that variable value, maybe it is null
Jason Luboff
@JLuboff
Nov 10 2017 17:50
@AdelMahjoub I'm not familar with ejs, but he has applications.forEach and then has the parameter application in the function
Adel
@AdelMahjoub
Nov 10 2017 17:50
@JLuboff ah, did not see that, ok
Mark White
@s3venvials
Nov 10 2017 17:50

Same error

ReferenceError: C:\Users\1211551\Desktop\node_js\qaah\views\index.ejs:537
535|

536| 

537| <% application.forEach(function(application){ %>

538|           <h4> <%= application.name %> </h4>

539|           <a href="<%= application.url %>">Test</a>

540|       <% }); %>
Ive tried all of this
its weird because thats how I have the other app and its fine
Adel
@AdelMahjoub
Nov 10 2017 17:52
@s3venvials push to github and link to the repo,
Mark White
@s3venvials
Nov 10 2017 17:52
okay give me a few
Ashwin
@ashwins93
Nov 10 2017 18:05
@s3venvials can you run mongo cli
and do a db.applications.find()
Mark White
@s3venvials
Nov 10 2017 18:05
yes
one sec
Ashwin
@ashwins93
Nov 10 2017 18:05
if your db is empty, mongoose will return undefined when you run Application.find({})
Adel
@AdelMahjoub
Nov 10 2017 18:06
@ashwins93 no problem
Blauelf
@Blauelf
Nov 10 2017 18:06
@Chrono79 Now I'm pretty sure I need arrays for this C puzzle. Those have weird abilities, for example is an array and a pointer to the array the same. I feel this might have a relevance.
Mark White
@s3venvials
Nov 10 2017 18:06
image.png
I have data in there
See why this is so puzzling
Ashwin
@ashwins93
Nov 10 2017 18:08
alright next step console.log(allApplications)
inside the get route
Mark White
@s3venvials
Nov 10 2017 18:08
I was hoping another pair of eyes could see my mistake, maybe a space or capital or something simple kinda going crazy lol
Ashwin
@ashwins93
Nov 10 2017 18:09
sometimes its puzzling, adding a console.log will help clear things up
Mark White
@s3venvials
Nov 10 2017 18:09
ill try it again but when I did that it returned nothing so its odd
stand by
Ashwin
@ashwins93
Nov 10 2017 18:11
on an unrelated note use a linter always
Mark White
@s3venvials
Nov 10 2017 18:11
You lost me :/
Ashwin
@ashwins93
Nov 10 2017 18:12
@s3venvials you are importing ('./models/application')
but the folder name is modules
how did it not throw an error for Application ?
Mark White
@s3venvials
Nov 10 2017 18:13
doh!
Ashwin
@ashwins93
Nov 10 2017 18:13
and the file name is application**s**.js
Mark White
@s3venvials
Nov 10 2017 18:13
oh you know what its right on my end but I messed it up when adding it to github
Ashwin
@ashwins93
Nov 10 2017 18:13
but you are importing application
Mark White
@s3venvials
Nov 10 2017 18:14
on my end its in the models folder with application.js
Ashwin
@ashwins93
Nov 10 2017 18:14
okay
did you try console.log(allApplications) before res.render()
Mark White
@s3venvials
Nov 10 2017 18:16
image.png
yup nothing other than the same error.
Adel
@AdelMahjoub
Nov 10 2017 18:16
@s3venvials there is something I don't unerstand, you have two request handler for GET /qaah
@s3venvials the first is the one that's trigger , where you render the username
Mark White
@s3venvials
Nov 10 2017 18:17
Ahh i forgot to combine them
maybe thats the problem
Kelechi Chinaka
@ke1echi
Nov 10 2017 18:18
nice trial, you would solve it eventually @Blauelf i can even place my hands on that :smile:
Mark White
@s3venvials
Nov 10 2017 18:19
Now were getting some where the console displayed the data from the DB but still error on the page. Maybe I need to render it again in instead of console.log
Ashwin
@ashwins93
Nov 10 2017 18:19
@AdelMahjoub good eyes
Mark White
@s3venvials
Nov 10 2017 18:20
Indeed!
Ashwin
@ashwins93
Nov 10 2017 18:20
express always redirects the first thing ignores the later one
Adel
@AdelMahjoub
Nov 10 2017 18:22
@s3venvials now you need the referenced variable in ejs to match what you need to render
Kristina
@kikidesignnet
Nov 10 2017 18:22
Can you check out this link: https://forum.freecodecamp.org/t/js-calculator-errors/157711/6 , please? I changed my code but I need to clear the array if an operator such as "+", "-", etc is pressed after an equation is done...
Adel
@AdelMahjoub
Nov 10 2017 18:22
@s3venvials res.render('index', { application: allApplications, username: '' }); it works as expected
Mark White
@s3venvials
Nov 10 2017 18:24
trying it now
I see so I have another req that im calling to display the logged in user name I would combine them? The other is to display the application name and URL

app.get("/qaah",isLoggedIn, function(req, res){
res.render("index", { username: req.user.username });

Application.find({}, function(err, allApplications){
if(err){
console.log(err);
} else {
res.render('index', { application: allApplications });
}
});
});

But instead I should combine the two request?
Adel
@AdelMahjoub
Nov 10 2017 18:27
@s3venvials combine or a new route for the applications
@s3venvials dashboard or anything
@s3venvials but do not respond twice in the request
Mark White
@s3venvials
Nov 10 2017 18:29

Better?

app.get("/qaah",isLoggedIn, function(req, res){
Application.find({}, function(err, allApplications){
if(err){
console.log(err);
} else {
res.render('index', { application: allApplications, username: req.user.username });
}
});
});

oh dang that worked! Thank you so much!
Adel
@AdelMahjoub
Nov 10 2017 18:30
@s3venvials if it suits your needs and it is working it should be good
Mark White
@s3venvials
Nov 10 2017 18:31
Lesson learned!
Kristina
@kikidesignnet
Nov 10 2017 18:31
Never mind. solved it!!
gurpm
@gurpm1991
Nov 10 2017 19:25
help please! how do I write this as a conventional function
selectActive = list.filter(function(list){
return list.active === true;
});
because everytime I try to submit it on sublime it states list is undefined
my test wants me to do it in this format
function selectActive(list){
}
sorry im such a noob
Tiago Correia
@tiagocorreiaalmeida
Nov 10 2017 20:05
shouts hello world
are you sure you wanna check if an element is equal to true? like literraly the boolean true ?
@gurpm1991
Tiago Correia
@tiagocorreiaalmeida
Nov 10 2017 20:19
@alpox around?
Kaz Baig
@kbaig
Nov 10 2017 20:32
He usually is at this time...
Jason Luboff
@JLuboff
Nov 10 2017 21:09
or is he..
Tiago Correia
@tiagocorreiaalmeida
Nov 10 2017 21:14
hey @JLuboff
Jason Luboff
@JLuboff
Nov 10 2017 21:14
What up
Ronique Ricketts
@RoniqueRicketts
Nov 10 2017 21:14
he is always lurking smh
Tiago Correia
@tiagocorreiaalmeida
Nov 10 2017 21:14
about to shoot myself no idea why I decided to try design a website... :D
Ronique Ricketts
@RoniqueRicketts
Nov 10 2017 21:15
@tiagocorreiaalmeida hahaha. Don't shoot yourself.
Jason Luboff
@JLuboff
Nov 10 2017 21:16
@tiagocorreiaalmeida Thats why I use frameworks... I'm lazy lol
Ronique Ricketts
@RoniqueRicketts
Nov 10 2017 21:16
@JLuboff we know :trollface:
Jason Luboff
@JLuboff
Nov 10 2017 21:16
Pinterest is coming along though..
blob
Tiago Correia
@tiagocorreiaalmeida
Nov 10 2017 21:18
looking good
Jason Luboff
@JLuboff
Nov 10 2017 21:18
@tiagocorreiaalmeida Thanks
CamperBot
@camperbot
Nov 10 2017 21:18
jluboff sends brownie points to @tiagocorreiaalmeida :sparkles: :thumbsup: :sparkles:
:cookie: 436 | @tiagocorreiaalmeida |http://www.freecodecamp.com/tiagocorreiaalmeida
Ronique Ricketts
@RoniqueRicketts
Nov 10 2017 21:18
@JLuboff Nice man. Where is this hosted?
Jason Luboff
@JLuboff
Nov 10 2017 21:19
@RoniqueRicketts Its localhost hence why I did a screenshot
Ronique Ricketts
@RoniqueRicketts
Nov 10 2017 21:20
@JLuboff looking nice so far man. Your doing well man. I always feel proud of you nerds. :)
Jason Luboff
@JLuboff
Nov 10 2017 21:23
@RoniqueRicketts Thanks. But you're a nerd too
CamperBot
@camperbot
Nov 10 2017 21:23
jluboff sends brownie points to @roniquericketts :sparkles: :thumbsup: :sparkles:
:cookie: 403 | @roniquericketts |http://www.freecodecamp.com/roniquericketts
Bryan Reese
@breese8009
Nov 10 2017 21:26
yello!!
Jason Luboff
@JLuboff
Nov 10 2017 21:27
Yolo
Ronique Ricketts
@RoniqueRicketts
Nov 10 2017 21:28
@JLuboff :O How rude. {peter griffin voice}
@breese8009 #FFFF00
Bryan Reese
@breese8009
Nov 10 2017 21:29
@RoniqueRicketts ?
Ronique Ricketts
@RoniqueRicketts
Nov 10 2017 21:29
@breese8009 yellow
Bryan Reese
@breese8009
Nov 10 2017 21:29
ah i c
lol
did u have to look that upp?
Jason Luboff
@JLuboff
Nov 10 2017 21:30
I knew that was a color hex, but wouldn'
t know whjich color
Bryan Reese
@breese8009
Nov 10 2017 21:31
@JLuboff ok soooooooo... I have this for login route...
  router.post('/api/login', function(req, res, next) {
    passport.authenticate('basic', {session:false}, function(err, user, token_record) {
      console.log(token_record, user)
      if (err) { return next(err) }
      res.json({access_token:token_record.access_token});
   })(req, res, next);

  });
and this

passport.use(new Strategy({ usernameField: "email"},

  function(email, password, done) {
      User.findOne({ email: email }, function(err, user) {
        console.log("got here")
        if (err) { return done(err); }
        if (!user) {
          return done(null, false, { message: 'Unknown user' });
        }
        if (password != 1212) {
          return done(null, false, { message: 'Invalid password' });
        }
        console.log('I just wanna see foo! '); // this fails!
        return done(null, user, aToken);

      });
  } 
))
above that route
Jason Luboff
@JLuboff
Nov 10 2017 21:33
Yes, yes
Bryan Reese
@breese8009
Nov 10 2017 21:34
from my front end im making a post request to the post login route on my back end that is sending this {email: "email@yahoo", password: "password"}
but for some reason that data sent isnt gettin there
Jason Luboff
@JLuboff
Nov 10 2017 21:36
Alright. So I haven't used the basic strategy before, just the local or oauth strats (facebook, twitter, github, etc)
What I would advise, stick a bunch of console.logs everywhere
See where it stops
Do you also have your serialize and deserialize functions?
Bryan Reese
@breese8009
Nov 10 2017 21:40
yea its in my controller
when i try it i get { message: 'Missing credentials' } false
im console.loggin it all lol
Ronique Ricketts
@RoniqueRicketts
Nov 10 2017 21:40
@breese8009 I know a few colors in my head
Bryan Reese
@breese8009
Nov 10 2017 21:40
ill figure it out
one day
Ronique Ricketts
@RoniqueRicketts
Nov 10 2017 21:42
i remember the #ff00ff my gf loves it so I automatically remember it. Unfortunately I can't throw this color code out of my head.
Jason Luboff
@JLuboff
Nov 10 2017 21:43
@breese8009 Maybe @cmccormack or @AdelMahjoub who have experience with react can step in?
Adel
@AdelMahjoub
Nov 10 2017 21:44
@JLuboff from which post the issue start
post the link to the github repo, better clone and check
Jason Luboff
@JLuboff
Nov 10 2017 21:46
@AdelMahjoub The code tidbit above
@breese8009 Provide your repo for @AdelMahjoub
Adel
@AdelMahjoub
Nov 10 2017 21:48
or the error you get in the browser
most of the time it is just a cors issue, between a dev server and an express app running in different port
a proxy property in package.json of the client devserver fix that kind of problem
for passport local strategy, the default name is local, if it is named basic, rename it basic when defining the strategy
Jason Luboff
@JLuboff
Nov 10 2017 21:53
Apparently there is a basic strategy which is similar to local, but doesn't use sessions? (I just quickly looked it up)
Adel
@AdelMahjoub
Nov 10 2017 21:54
if it is just for token you can get rid of passport, a small function that authenticate the user and generate a jwt is all what you need
Jason Luboff
@JLuboff
Nov 10 2017 21:56
@breese8009 Damn it...why do you always disappear after asking a question? :joy:
Adel
@AdelMahjoub
Nov 10 2017 21:56
when a request come, an authentication middleware catch it first, verify the token, if valid attach the auth user to the request object, if not next(err) => unauthorized
since it is attached to the requset object it will be available for all the rest of the middleware chain
all what you need is jsonwebtoken module
but if you need more strategies, then maybe passport is a better choice
Bryan Reese
@breese8009
Nov 10 2017 22:09
@JLuboff yo i fucking did it!!!!!!!!!!!!!!!!!!!
holy shit!!!!!!
ive been at this for over a week
@cmccormack @JLuboff @AdelMahjoub i did it
thank u guys!
Jason Luboff
@JLuboff
Nov 10 2017 22:10
:+1:
At least give us some damn brownies fool
Bryan Reese
@breese8009
Nov 10 2017 22:10
oh it didnt work
@JLuboff @cmccormack @AdelMahjoub TY!
CamperBot
@camperbot
Nov 10 2017 22:10
:cookie: 615 | @adelmahjoub |http://www.freecodecamp.com/adelmahjoub
:star2: 1269 | @cmccormack |http://www.freecodecamp.com/cmccormack
breese8009 sends brownie points to @jluboff and @cmccormack and @adelmahjoub :sparkles: :thumbsup: :sparkles:
:star2: 2258 | @jluboff |http://www.freecodecamp.com/jluboff
Jason Luboff
@JLuboff
Nov 10 2017 22:10
OH yummmy
Bryan Reese
@breese8009
Nov 10 2017 22:11
check it out...
Screen Shot 2017-11-10 at 2.10.29 PM.png
hahahahahahahahaha
im so damn happy right now
Jason Luboff
@JLuboff
Nov 10 2017 22:12
Nice man, good job
Bryan Reese
@breese8009
Nov 10 2017 22:12
So I changed to local strategy
Jason Luboff
@JLuboff
Nov 10 2017 22:14
Thats it?
Bryan Reese
@breese8009
Nov 10 2017 22:15
and i had to changed some shit in react
i was just frusterated with it
frustrated
so i gave up on it for a while and went to okta
but that doesnt feel right to do that
Jason Luboff
@JLuboff
Nov 10 2017 22:19
:+1:
I think I always make this things a big mess in my head I got a solution but I feel there's probably a alot easier away of solving it
if someone can do it as post your solution
Jason Luboff
@JLuboff
Nov 10 2017 23:47
Apparently I started this before but didn't finish..lets see
Tiago Correia
@tiagocorreiaalmeida
Nov 10 2017 23:48
It has 9lines my solution but meh
xd
seems to much workaround for it
too*
Jason Luboff
@JLuboff
Nov 10 2017 23:59
Argh..only thing messing me up right now is the capitalization