Problem embedding quote on Twitter (Random Quote Machine project)

Hello Everyone! I’m stuck with this problem: When I press the twitter button to share a quote on Twitter, it doesn’t fully display the quote and omit the author, but sometimes it does work fine. Any idea why? Thank you in advance! :smile:

Here is my codepen: https://codepen.io/Flor95/full/dyYOzRr

So I noticed that semicolons are ruining the quotes because it cannot be used in urls. If you filter out those types of characters, I reckon it will work. Good luck to ya! :slightly_smiling_face:

1 Like

Thank you looking at my code @CaraLagumen, I truly appreciate it.
I just did what you suggested me but still doesn’t work. I don’t know why it works with most of the quotes but some seem to break :thinking: :pensive:

No problem. Did you try to find out what from the quote could possibly be breaking it still? I would try logging all the quotes that break it to narrow the problem down.

I used this and it seemed to solve it though. Could you check if this works for you?

this.setState({
      quote: randomQuote.quote.toString().replace(/;/g, ','),
      author: randomQuote.author
    })
1 Like

Thank you again! I tried using encodeURIComponent() for both the quote and the author and it finally solved it! Thank so so so much :star_struck: :grinning: :grinning:

1 Like

That’s great! I learn something new today too, so thanks! :rofl:

1 Like