These are chat archives for FreeCodeCamp/HelpJavaScript

24th
Mar 2018
Markus Kiili
@Masd925
Mar 24 2018 08:54
@gulsvi I think that I have a one-line solution of Exact change on my gist on FCC one-liners.
Dardan Demiri
@dardandmr
Mar 24 2018 13:05
@NJM8
why is your wikipedia viewer not workin
working
Sorry there was an error or no results from your query, try searching again!
Whatever I search the same message appears
even when I press Random Search
the same error
Sorry there was an error or no results from your query, try searching again!
@NJM8 And your local weather by Gif! is so funny !! hahaha great idea
Muhammad Hasham
@MohammadHasham
Mar 24 2018 14:37
i just need some advice with mongodb,
actually i want t o implement the like functionality (as it is in facebook), if a user presses the like button it shall be liked, and if the same user again presses the like button it gets disliked, moreover, each user should know what posts he has liked, like we see in facebook, the liked post has a changed color on the like button, i just want to know generally,what would be the best schema design for this.
I hope i was able to elaborate myself clearly,
Regards.
Tiago Correia
@tiagocorreiaalmeida
Mar 24 2018 16:28
hey @MohammadHasham I have made it a few times still not sure if I do it the best way possible but imagine a post, you have a document that's a post and that post has a value called likes and that value is an array in that array you store the user id that liked the post
later on you can check that if the user id is on the likes array if so you change that button color
Nate Mallison
@NJM8
Mar 24 2018 19:24
@dardandmr Thanks, The gif idea came in a twisted desire to combine as many api's as possible, I had three in there originally. I'm not sure why the wikipedia viewer isn't working. It is for me. do you have any errors in the console?
CamperBot
@camperbot
Mar 24 2018 19:24
njm8 sends brownie points to @dardandmr :sparkles: :thumbsup: :sparkles:
:cookie: 307 | @dardandmr |http://www.freecodecamp.org/dardandmr
Nate Mallison
@NJM8
Mar 24 2018 19:25
@Masd925 that is something I would like to see.
Dardan Demiri
@dardandmr
Mar 24 2018 19:54
blob
@NJM8
The same is when making a Random Search
blob
A formated version
Dingly Do
@dinglydo
Mar 24 2018 22:05
Problem: I just finished the JSON APIs and Ajax, and now I am at the intermediate projects section. For the first project, Random Quote Machine, you have to interact with a quote generator API. However, I seem to be having problems with the $.getJSON. The code inside the function won't run at all, and it doesn't seem to be printing any errors either. This is my Javascript code:
$(document).ready(function()
{
$.getJSON("https://www.freecodecamp.org/json/cats.json", function(data)
{
    console.log(data.stringify());
});    
});
So is there any reason why it's not working?
Matej Bošnjak
@mbosnjak01
Mar 24 2018 22:06
try just console.log(data) for a start
Dingly Do
@dinglydo
Mar 24 2018 22:06
Ran it, nothing printed to the console
image.png
And I do have Jquery Linked
Diego Mayer
@Chrono79
Mar 24 2018 22:10
@dinglydo it's JSON.stringify(data)
Dingly Do
@dinglydo
Mar 24 2018 22:10
Still doesn't help, I don't think the code is running at all
Matej Bošnjak
@mbosnjak01
Mar 24 2018 22:10
index.html:1 Failed to load https://www.freecodecamp.org/json/cats.json: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://s.codepen.io' is therefore not allowed access.
this is why
at least that's what i get in codepen
Dingly Do
@dinglydo
Mar 24 2018 22:11
How do you get that?
Diego Mayer
@Chrono79
Mar 24 2018 22:11
open developer console
Dingly Do
@dinglydo
Mar 24 2018 22:11
Oh I see
Diego Mayer
@Chrono79
Mar 24 2018 22:11
ctrl + shift + j in Chrome or F12 in other browsers
Dingly Do
@dinglydo
Mar 24 2018 22:11
image.png
I thought it would print on the Codepen console
So would it work with other APIs?
Imma check real quick
It works, thanks @mbosnjak01 @Chrono79
CamperBot
@camperbot
Mar 24 2018 22:14
dinglydo sends brownie points to @mbosnjak01 and @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 4613 | @chrono79 |http://www.freecodecamp.org/chrono79
:cookie: 255 | @mbosnjak01 |http://www.freecodecamp.org/mbosnjak01
Matej Bošnjak
@mbosnjak01
Mar 24 2018 22:14
:+1:
Diego Mayer
@Chrono79
Mar 24 2018 22:15
no problem
Nate Mallison
@NJM8
Mar 24 2018 23:51
@dardandmr What browser are you using? And what are some of the queries you tried? I thought I covered a failed response from wikipedia api but maybe not