Tolga Gunduz
Posts: 0
Joined: Wed Sep 10, 2014 3:26 pm

Access Database Outside Appery

Here is the code:

database-id is not valid - dont want to share.

What is missing here?

alert('starting..');
$.ajax({
url: "https://api.appery.io/rest/1/db/colle...",
beforeSend: function(xhr) {
xhr.setRequestHeader("X-Appery-Database-Id", "549883b8e4b0611a100c6121");

},
success: function(data) {
alert(data.from);
},
error:function(data) {
alert(data);
}
});

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Access Database Outside Appery

Hello Tolga,

I don't see a problem with the code. Everything looks fine. Could you please look in the browser console what happens when you run the code, are there any errors? What returns the service? http://devcenter.appery.io/documentat...

EJLD
Posts: 0
Joined: Sun Jun 08, 2014 11:03 pm

Access Database Outside Appery

Hi there, this topic is what I am looking for to get started with XHR from an outside website.
however, for some reasons I must use JS instead of JQ.
as you all know I am totally new at many things.
may I ask you for the equiv in JS of your example

$.ajax({
url: "https://api.appery.io/rest/1/db/colle...",
beforeSend: function(xhr) {
xhr.setRequestHeader("X-Appery-Database-Id", "51d5662de4b0b3e9055d450a");
},
success: function(data) {
}
});

it would help me to get started
thk you very much in advance
Eric

EJLD
Posts: 0
Joined: Sun Jun 08, 2014 11:03 pm

Access Database Outside Appery

that helped me very much.
you guys at Appery still do great !

EJLD
Posts: 0
Joined: Sun Jun 08, 2014 11:03 pm

Access Database Outside Appery

Hello, again those few line of code helped me very much. thk you.
May I ask you how I can pass the param (session token ...) to access to the Users table/collection ?
thk you very much in advance,
Eric

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Access Database Outside Appery

Hello, You have to add it into request's header as it is described here: https://devcenter.appery.io/documenta...

EJLD
Posts: 0
Joined: Sun Jun 08, 2014 11:03 pm

Access Database Outside Appery

Hi Sergiy, thks for your prompt reply.
I'll look into this.
Best,
Eric

PS: long time not being on appery's forum (I put a side my app dev to focus on promo website). how you guys doing ?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Access Database Outside Appery

Hello Eric,

Hope I can speak on behalf of all support team, we are fine, thank you. Hope you too. We're currently working on the next release, well as usual.
I leave your other post with the kind words to Illiya or Alyona for they could have the possibility to say you how we are grateful and missed you :)

EJLD
Posts: 0
Joined: Sun Jun 08, 2014 11:03 pm

Access Database Outside Appery

Hi There, I could log in my appery DB from an outside site (happy :) ).
however, my JS is visible in the browser console and disclose the username and password to login to that DB :(
here attd is my ajax code.
would you have a trick like a char format supported by the appery server and which would hide those info ? (any line of code to fix that stuff is welcome :) )
thk you in advance
Eric

Image

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Access Database Outside Appery

Hello,

Please use JS below for logging to the DB:
pre$.ajax({
url: "https://api.appery.io/rest/1/db/login",
method: "GET",
context: document.body,
headers:{
"Accept": "application/json",
"X-Appery-Database-Id": "516fb7c3e4b050d8f16ccf9a",
"Content-Type": "application/json"
},
data :{
username: "test",
password:"test"
},
'contentType': 'application/json',
dataType:"json"

Code: Select all

 }).done(function(data){ 
         console.log(JSON.parse(data)); 

});/pre

Return to “Issues”