The Database Hub is home for developers who want to clone, connect, and share databases and build apps together. By connecting to a database, you can easily consume its data using an API (GraphQL or REST) or via SDK.
when i'm trying to request the states for specific country it returns this error 500 Internal server error
You have to use the country object id (and not the name). For example, if you search for China, you will see this response:
{
"results": [
{
"objectId": "jPsWdF78Gn",
"code": "CN",
"name": "China",
"native": "中国",
"phone": "86",
"continent": {
"__type": "Pointer",
"className": "Continent",
"objectId": "mSxk54vkg6"
},
"capital": "Beijing",
"currency": "CNY",
"emoji": "🇨🇳",
"emojiU": "U+1F1E8 U+1F1F3",
"createdAt": "2019-12-09T21:27:25.283Z",
"updatedAt": "2020-04-13T18:17:24.023Z",
"geonameid": 1814991,
"shape": {
"__type": "Pointer",
"className": "Shape",
"objectId": "PpZLJvCZ04"
},
"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, in order to query for China's cities, you would need to use the following request:
<html>
<head></head>
<body>
<script type="text/javascript">
(async () => {
const where = encodeURIComponent(JSON.stringify({
"country": {
"__type": "Pointer",
"className": "Country",
"objectId": "jPsWdF78Gn"
}
}));
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));
})();
</script>
</body>
</html>
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.