From a Sheet to a complete Database you can share any Data on the HUB. Create your Database, Import your data, Publish on the HUB ,and Customize your Database Page.
I've used the example code to try and query the Subdivisions_States_Provinces endpoint for results within a specific country code and used a couple of country codes to test, but nothing is returned.
Any assistance would be greatly appreciated.
Regards, Paul
The same happens when querying the cities endpoint.
I am using the javascript examples
You have to use the country object id (and not the code). For example, if you search for US, you will see this response:
{
"results": [
{
"objectId": "BXkZTl2omc",
"code": "US",
"name": "United States",
"native": "United States",
"phone": "1",
"continent": {
"__type": "Pointer",
"className": "Continent",
"objectId": "vZNZcahFvu"
},
"capital": "Washington D.C.",
"currency": "USD,USN,USS",
"emoji": "🇺🇸",
"emojiU": "U+1F1FA U+1F1F8",
"createdAt": "2019-12-11T08:14:17.654Z",
"updatedAt": "2020-04-13T18:19:25.532Z",
"geonameid": 6252001,
"shape": {
"__type": "Pointer",
"className": "Shape",
"objectId": "sb3piMeMV9"
},
"languages": {
"__type": "Relation",
"className": "Language"
},
"cities": {
"__type": "Relation",
"className": "City"
},
"timezones": {
"__type": "Relation",
"className": "Timezone_Time_Zones_Dataset"
},
"provinces": {
"__type": "Relation",
"className": "Subdivisions_States_Provinces"
}
}
]
}
So, searching for US cities, would require you to use the following request:
(async () => {
const where = encodeURIComponent(JSON.stringify({
"country": {
"__type": "Pointer",
"className": "Country",
"objectId": "BXkZTl2omc"
}
}));
const response = await fetch(
`https://parseapi.back4app.com/classes/City?limit=10&where=${where}`,
{
headers: {
'X-Parse-Application-Id': 'mxsebv4KoWIGkRntXwyzg6c6DhKWQuit8Ry9sHja', // This is the fake app's application id
'X-Parse-Master-Key': 'TpO0j3lG2PmEVMXlKYQACoOXKQrL3lwM0HwR9dbH', // This is the fake app's readonly master key
}
}
);
const data = await response.json(); // Here you have the data that you need
console.log(JSON.stringify(data, null, 2));
})();
Thanks for the advice @davimacedo. I also realised that there's an issue with the endpoint names in the generated code. The one for countries is correct, but the one for subdivisions is not 'Subdivisions_States_Provinces', it's 'Continentscountriescities_Subdivisions_States_Provinces' and the one for cities is not 'City', it's 'Continentscountriescities_City'. Having got that right, and with your advice, I got it all working.
I am glad you figured it out. When talking about the endpoint names, please note that they change wether you are using the fake app or your own app. I mean, if you select one of your apps in the step 1 of the get started, it should generate the code with the right names.
We use cookies to provide our services and for analytics and marketing. To find out more about our use of cookies, please see our Terms of Service and Privacy Policy . By continuing to browse our website, you agree to our use of cookies.