Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
Ariel
@abibliophile
@GregatGit i just did the section about APIs and they put their js in the html section in between script tags? Is there a reson why that doesn't work?
Greg Duncan
@GregatGit
@abibliophile You are only getting one quote so you can simplify your js - you don't need to use Oject.keys foreach
you just need to have the html set up and input the text when the api works
Ariel
@abibliophile
hm, okay
let me think that through
thanks for pointing me in the right direction @GregatGit !
CamperBot
@camperbot
abibliophile sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:star: 415 | @gregatgit | http://www.freecodecamp.com/gregatgit
Greg Duncan
@GregatGit
@abibliophile you got the right api and this what should come down
{
"success": {
"total": 1
},
"contents": {
"quotes": [
{
"quote": "All our dreams can come true – if we have the courage to pursue them.",
"length": "77",
"author": "Walt Disney",
"tags": [
"dreams",
"inspire"
],
"category": "inspire",
"date": "2016-04-14",
"title": "Inspiring Quote of the day",
"background": "https://theysaidso.com/img/bgs/man_on_the_mountain.jpg",
"id": "SWNQixrw7xrdBDh_ujjddQeF"
}
]
}
}
Bruce Young
@mutantspore
@abibliophile this wil get your quote shown in the console. I don’t know anything about the api… it seems to just get the same one each time
 $(document).ready(function() {
   $(".btn").on("click", function() {
     $.getJSON("http://quotes.rest/qod.json", function(json) {
       console.log(json);
       console.log(json.contents.quotes[0].quote);
       console.log(json.contents.quotes[0].author);

     });
   });
 });
@abibliophile @GregatGit yes.. Quote of the Day… perhaps one per day????
arjunpunnam
@arjunpunnam
Hi im getting this error while using the Quotes Api in Quote Generator
No 'Access-Control-Allow-Origin' header is present on the requested resource
Can some help please?
Stephen James
@sjames1958gm
@arjunpunnam You have run into the cross origin problem that many before you have. Generally you have to resort to jsonp a protocol for getting around this. But I don't think the website you are trying to access supports jsonp
Daniel Gonzales
@choppd
@sjames1958gm How would you work around this, I'm also having trouble with this.
Greg D
@mosaic-greg
imho troubleshooting front end is harder than troubleshooting js
Stephen James
@sjames1958gm
@choppd What URL/api are you using?
for the quote project I just put the quotes in an array and randomly selected them.
Daniel Gonzales
@choppd
Same as the person you responded to. http://quotes.stormconsultancy.co.uk/random.json
Stephen James
@sjames1958gm
Looks like that is a pretty meager api.
Not sure how they are expecting you to use it with this issue.
Daniel Gonzales
@choppd
@sjames1958gm So you're saying that the data isn't in json, and you can't use .getJSON()
Matt Yamamoto
@MattYamamoto
@sjames1958gm @arjunpunnam I don't think that API supports JSONP. You could proxy it via this site https://jsonp.afeld.me/, which would give you this link https://jsonp.afeld.me/?callback=?&url=http://quotes.stormconsultancy.co.uk/random.json to use
Stephen James
@sjames1958gm
@choppd The data is json, without jsonp the browser cannot/will not give you the data . See ^^^ @MattYamamoto
Matt Yamamoto
@MattYamamoto
oh yeah, whoops...mentioned the wrong person. :smile:
Stephen James
@sjames1958gm
@MattYamamoto All good :)
Daniel Gonzales
@choppd
@sjames1958gm @MattYamamoto Ahh I see now! Thanks!!!
CamperBot
@camperbot
choppd sends brownie points to @sjames1958gm and @mattyamamoto :sparkles: :thumbsup: :sparkles:
:star: 629 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
:star: 954 | @mattyamamoto | http://www.freecodecamp.com/mattyamamoto
Daniel Gonzales
@choppd
That works! Wow, been stuck on that for a long time
Michael Karpinski
@karpimpski
@tuningmind sorry for the late reply, but yes. I've gone through it. why?
$.getJSON('https://api.twitch.tv/kraken/streams/freecodecamp?callback=?', function(data) {
  console.log(data);
});
copied this from the suggested link to see if it works and it doesn't. when I type it in without the callback at the end I get the JSON data on my browser though
Michael Karpinski
@karpimpski
I've tried setting the callback to callback=false, but that didn't work. still not getting any data logged to my console. any help would be great!
Stephen James
@sjames1958gm
@karpimpski Try console.log(JSON.stringify(data));
Matt Yamamoto
@MattYamamoto
@karpimpski link to your pen?
Michael Karpinski
@karpimpski
@sjames1958gm nope :/
Stephen James
@sjames1958gm
@karpimpski Jquery included in js?
Matt Yamamoto
@MattYamamoto
yeah, that's the issue
Michael Karpinski
@karpimpski
@sjames1958gm that's the second time you got me on that. thanks, I always forget to include JQuery
CamperBot
@camperbot
karpimpski sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 630 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Michael Karpinski
@karpimpski
works great now. thanks guys! @MattYamamoto @sjames1958gm
Matt Yamamoto
@MattYamamoto
@karpimpski That's why the browser's console is a bit more helpful than codepen's console.... your browser will show you errors.
Michael Karpinski
@karpimpski
@MattYamamoto I'm sure this sounds like a noob question, but how do you use the browser's console?
Matt Yamamoto
@MattYamamoto
@karpimpski I think it might depend on the browse, but try hitting F12 and see what that does.