Hey guys, I’m making an app where I pull location data based on the Zip code given. Is there a way to make thunkable give me data for the first 3 digits of the zip code matching locations instead of having a complete zip code? Im just trying to make it pull more general data. Need help ASAP. Thanks!
Welcome to the community @jtianga23lf!
If I understood correctly what your trying to do is something like this:
Zip code: 123456 → get first three digits: 123
If so, try this block:
Just set the zip code to the abc part and get the substring from letter #1 to letter #3
Hope this helps!
If your API allows it, then sure.
Which API are you using?
Looks good, I’ll let you know. Thanks so much!
can you plz help me in my q
can you plz help me in my q.
I don’t know what you’re referring to. If there’s another topic you want help with, just post an update with more details, etc. You can also refer to another topic by clicking the link icon below the post and then copying and pasting it into a new post.
Any chance you can post the text of the full JSON response you’re getting? If you put the URL in a browser, you can then see that response.
It looks like you’re off to a good start. I discuss that step and what’s helpful to post when troubleshooting APIs in this tutorial post: API JSON Tutorial (Video).
Its a very long reponse. I’ll just give you the link.
https://covid-19-testing.github.io/locations/new-york/complete.json
That’s really helpful! If you copy and paste that full response into a JSON formatter such as Best JSON Viewer and JSON Beautifier Online, you can view the structure of the JSON. On that site, click Tree Viewer and then on the right side, you can either browse or search for a property name.
If you’re trying to get the zip code, I believe you’ll want to use the postal code. If you click on that property, as in the screenshot below, you can start to construct the path to the property (listed at the top of the screenshot). Note that any property with square brackets [ ] indicates a JSON array and wil need to be accessed using list blocks in Thunkable. I cover all of that in my tutorial video, FYI.
I was able to get the location data when putting in a full zip code
. How can i integrate the get substring line into what I have to use a partial postal code? The block I plan to use is above my to getDataList chain.You can check to see if the variable “zip” is equal to the substring from letter #1 to #3 of the variable “Location Zip”. So you’d put “app variable Location Zip” in the “abc” field and then change the “2” to “3” for the letter #.
Where do i put this new string of code?
Awesome, it works! Thanks so much!