Server code query to users database returns 200 whether records exist or not
I have a server code will create an email invitation if a user does not exist. My code works perfectly and I have removed the - thanks to the great tutorials and guidance here with one exception. I am testing with a valid token, database id and masterkey
Even if the user does not exist the XHRResponse.status is 200 (and therefore the next step generates an uncaught error)
What have I done wrong?
My code is var responseBody = {},
requestParams = {},
paramKeys = request.keys();
for (var key = 0; key < paramKeys.length; key++) {
requestParams[paramKeys[key]] = request.get(paramKeys[key]);
}
var dbId = "";
var masterKey = "";
var tokenId = requestParams["tokenId"];
var email = requestParams["emailInvite"];
var XHRResponse = XHR.send("GET", "https://api.appery.io/rest/1/db/users", { // return the userid for the given user
"headers": {
"X-Appery-Database-Id": dbId,
"X-Appery-Master-Key": masterKey
},
"parameters": {
"where": '{"username":"' + email + '"}'}
});
if (XHRResponse.status === 200) {
do everything else and send email from server
}