![]() ![]() But this, too, would have required me to be able to edit code that I couldn't access. I did some Googling and learned about something called CORS that allows you to configure cross-domain requests like these. I have no control over either of these things, so what could I do? This error meant that it was unsafe to connect from HTTPS on Codepen to HTTP at the Word Game Dictionary API. "This request has been blocked the content must be served over HTTPS." Instead of receiving the XML I expected, I was receiving an error: "Mixed Content: The page at was loaded over HTTPS, but requested an insecure resource. īut! This is where I ran into my first challenge. The word I sent is in the tag, and the validity for SCRABBLE is stored in the scrabble tag - 1 if it's valid, 0 if it's invalid. error to trigger if no successful responseĬonsole.log("API error: cannot contact the dictionary") Īfter I call the API, I should have XML in the following format. then(str => (new window.DOMParser()).parseFromString(str, "text/xml")) ![]() Then I need to receive the response (a stream object), and parse it to XML. Even though browser support isn't yet very high, I decided to use the Fetch API for its ease of use, as I'm not very well-versed on using APIs.Įvery time I call the API, I need to include the search word and my API key. The first step was to register with Word Game Dictionary and get an API key (a unique way to identify myself when I call the API). The Word Game Dictionary API takes a word and returns an evaluation of that word for several word games (e.g., SCRABBLE, Words With Friends) in an XML format. So I set out to build my own front end for a SCRABBLE word checking tool. My first thought was, is there some kind of API that will return SCRABBLE dictionary results? After a little digging, I found one at the site Word Game Dictionary. We also kept looking up the list of 2-letter SCRABBLE words("QI", anyone?), which is normally found inside the SCRABBLE box. There are official SCRABBLE dictionaries for this purpose, but we don't own one. SCRABBLE validity isn't as simple as finding a definition for a word, as there are plenty of words found in a dictionary that aren't valid in SCRABBLE. While playing SCRABBLE over my holiday break, I noticed that my partner and I were frequently using our phones to check whether certain words were valid in SCRABBLE. If you read this and notice an area where I could make some improvements in my code, please let me know! This was my first time using the Fetch API, for example, and I have a lot more to learn. I'll explain how I approached the project, the challenges I encountered, and how I resolved them. This is a guided walk-through of how I built a SCRABBLE word checker. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |