Random quote machine, API will not return a new quote The Next CEO of Stack OverflowWhen to use double or single quotes in JavaScript?Generate random string/characters in JavaScriptevent.preventDefault() vs. return falseGenerating random whole numbers in JavaScript in a specific range?What is the 'new' keyword in JavaScript?How to randomize (shuffle) a JavaScript array?Open a URL in a new tab (and not a new window) using JavaScriptGenerate random number between two numbers in JavaScriptWhy does ++[[]][+[]]+[+[]] return the string “10”?How do I return the response from an asynchronous call?
Is there a rule of thumb for determining the amount one should accept for a settlement offer?
Mathematica command that allows it to read my intentions
What is a typical Mizrachi Seder like?
Could a dragon use its wings to swim?
What steps are necessary to read a Modern SSD in Medieval Europe?
Calculate the Mean mean of two numbers
That's an odd coin - I wonder why
What happens if you break a law in another country outside of that country?
How to find if SQL server backup is encrypted with TDE without restoring the backup
How to pronounce fünf in 45
Does Germany produce more waste than the US?
How to unfasten electrical subpanel attached with ramset
Is it "common practice in Fourier transform spectroscopy to multiply the measured interferogram by an apodizing function"? If so, why?
Physiological effects of huge anime eyes
Can a PhD from a non-TU9 German university become a professor in a TU9 university?
How to show a landlord what we have in savings?
Planeswalker Ability and Death Timing
Finitely generated matrix groups whose eigenvalues are all algebraic
What does this strange code stamp on my passport mean?
Why can't we say "I have been having a dog"?
Strange use of "whether ... than ..." in official text
Avoiding the "not like other girls" trope?
Read/write a pipe-delimited file line by line with some simple text manipulation
Compensation for working overtime on Saturdays
Random quote machine, API will not return a new quote
The Next CEO of Stack OverflowWhen to use double or single quotes in JavaScript?Generate random string/characters in JavaScriptevent.preventDefault() vs. return falseGenerating random whole numbers in JavaScript in a specific range?What is the 'new' keyword in JavaScript?How to randomize (shuffle) a JavaScript array?Open a URL in a new tab (and not a new window) using JavaScriptGenerate random number between two numbers in JavaScriptWhy does ++[[]][+[]]+[+[]] return the string “10”?How do I return the response from an asynchronous call?
So i build entire project in Visual Studio Code, I tested it on Chrome and Explorer and it works, it retrieves a new quote and an author with the press of a button, great i thought time to put it into codepen, nope, doesn’t work. Here is what happens, i am using http://quotesondesign.com/api-v4-0/ to get my quotes, when you put this into a browser you see what it retrieves
http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1
the problem seems that on firefox if you enter this you will get a quote, however, if you enter the same link(note that not refresh the page but use the same link) you will get the same quote, in chrome, however, it will give you a new quote, sooooo i tried to see if it would work if I used codepen on chrome, and it didnt work at all because on chrome codepen the api call wouldnt even retrieve any data. here is a function I am using right now.
my code for getting new function looks like this.
getRandomQuote = event =>
fetch('https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1')
.then(response => response.json())
.then(data =>
if(data[0].content && data[0].title && data[0].link)
let quote = this.state;
let quoteData=data[0];
quote.content = quoteData.content;
quote.link = quoteData.link;
quote.title = quoteData.title;
this.setState(
quote,
isLoaded:true
)
else
return console.error('No Quote :(')
)
here is a link for my codepen:https://codepen.io/russiandobby/pen/OqaxWW?editors=1111
How can I get it to retrieve new cote?
javascript reactjs api
add a comment |
So i build entire project in Visual Studio Code, I tested it on Chrome and Explorer and it works, it retrieves a new quote and an author with the press of a button, great i thought time to put it into codepen, nope, doesn’t work. Here is what happens, i am using http://quotesondesign.com/api-v4-0/ to get my quotes, when you put this into a browser you see what it retrieves
http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1
the problem seems that on firefox if you enter this you will get a quote, however, if you enter the same link(note that not refresh the page but use the same link) you will get the same quote, in chrome, however, it will give you a new quote, sooooo i tried to see if it would work if I used codepen on chrome, and it didnt work at all because on chrome codepen the api call wouldnt even retrieve any data. here is a function I am using right now.
my code for getting new function looks like this.
getRandomQuote = event =>
fetch('https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1')
.then(response => response.json())
.then(data =>
if(data[0].content && data[0].title && data[0].link)
let quote = this.state;
let quoteData=data[0];
quote.content = quoteData.content;
quote.link = quoteData.link;
quote.title = quoteData.title;
this.setState(
quote,
isLoaded:true
)
else
return console.error('No Quote :(')
)
here is a link for my codepen:https://codepen.io/russiandobby/pen/OqaxWW?editors=1111
How can I get it to retrieve new cote?
javascript reactjs api
add a comment |
So i build entire project in Visual Studio Code, I tested it on Chrome and Explorer and it works, it retrieves a new quote and an author with the press of a button, great i thought time to put it into codepen, nope, doesn’t work. Here is what happens, i am using http://quotesondesign.com/api-v4-0/ to get my quotes, when you put this into a browser you see what it retrieves
http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1
the problem seems that on firefox if you enter this you will get a quote, however, if you enter the same link(note that not refresh the page but use the same link) you will get the same quote, in chrome, however, it will give you a new quote, sooooo i tried to see if it would work if I used codepen on chrome, and it didnt work at all because on chrome codepen the api call wouldnt even retrieve any data. here is a function I am using right now.
my code for getting new function looks like this.
getRandomQuote = event =>
fetch('https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1')
.then(response => response.json())
.then(data =>
if(data[0].content && data[0].title && data[0].link)
let quote = this.state;
let quoteData=data[0];
quote.content = quoteData.content;
quote.link = quoteData.link;
quote.title = quoteData.title;
this.setState(
quote,
isLoaded:true
)
else
return console.error('No Quote :(')
)
here is a link for my codepen:https://codepen.io/russiandobby/pen/OqaxWW?editors=1111
How can I get it to retrieve new cote?
javascript reactjs api
So i build entire project in Visual Studio Code, I tested it on Chrome and Explorer and it works, it retrieves a new quote and an author with the press of a button, great i thought time to put it into codepen, nope, doesn’t work. Here is what happens, i am using http://quotesondesign.com/api-v4-0/ to get my quotes, when you put this into a browser you see what it retrieves
http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1
the problem seems that on firefox if you enter this you will get a quote, however, if you enter the same link(note that not refresh the page but use the same link) you will get the same quote, in chrome, however, it will give you a new quote, sooooo i tried to see if it would work if I used codepen on chrome, and it didnt work at all because on chrome codepen the api call wouldnt even retrieve any data. here is a function I am using right now.
my code for getting new function looks like this.
getRandomQuote = event =>
fetch('https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1')
.then(response => response.json())
.then(data =>
if(data[0].content && data[0].title && data[0].link)
let quote = this.state;
let quoteData=data[0];
quote.content = quoteData.content;
quote.link = quoteData.link;
quote.title = quoteData.title;
this.setState(
quote,
isLoaded:true
)
else
return console.error('No Quote :(')
)
here is a link for my codepen:https://codepen.io/russiandobby/pen/OqaxWW?editors=1111
How can I get it to retrieve new cote?
javascript reactjs api
javascript reactjs api
asked Mar 21 at 19:58
russiandobbyrussiandobby
12
12
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Ok, now I feel stupid, after some research i found that it seems that all i had to do is change my request a little bit from
fetch('https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1')
to
fetch('https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1', cache: "reload")
after i did that, it started to work on all browsers and retriving new quotes, i been banning m had for 2 hours and all it took is less then 1 line to fix itT_T
add a comment |
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55288388%2frandom-quote-machine-api-will-not-return-a-new-quote%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Ok, now I feel stupid, after some research i found that it seems that all i had to do is change my request a little bit from
fetch('https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1')
to
fetch('https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1', cache: "reload")
after i did that, it started to work on all browsers and retriving new quotes, i been banning m had for 2 hours and all it took is less then 1 line to fix itT_T
add a comment |
Ok, now I feel stupid, after some research i found that it seems that all i had to do is change my request a little bit from
fetch('https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1')
to
fetch('https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1', cache: "reload")
after i did that, it started to work on all browsers and retriving new quotes, i been banning m had for 2 hours and all it took is less then 1 line to fix itT_T
add a comment |
Ok, now I feel stupid, after some research i found that it seems that all i had to do is change my request a little bit from
fetch('https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1')
to
fetch('https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1', cache: "reload")
after i did that, it started to work on all browsers and retriving new quotes, i been banning m had for 2 hours and all it took is less then 1 line to fix itT_T
Ok, now I feel stupid, after some research i found that it seems that all i had to do is change my request a little bit from
fetch('https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1')
to
fetch('https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1', cache: "reload")
after i did that, it started to work on all browsers and retriving new quotes, i been banning m had for 2 hours and all it took is less then 1 line to fix itT_T
edited Mar 21 at 20:15
answered Mar 21 at 20:09
russiandobbyrussiandobby
12
12
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55288388%2frandom-quote-machine-api-will-not-return-a-new-quote%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown