Page 3 of 4

Access Database Outside Appery

Posted: Mon Sep 15, 2014 1:31 pm
by Tolga Gunduz

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);
}
});


Access Database Outside Appery

Posted: Mon Sep 15, 2014 6:39 pm
by Evgene Karachevtsev

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...


Access Database Outside Appery

Posted: Mon Oct 19, 2015 9:43 pm
by EJLD

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


Access Database Outside Appery

Posted: Tue Oct 20, 2015 1:38 pm
by EJLD

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


Access Database Outside Appery

Posted: Fri Oct 23, 2015 10:02 am
by EJLD

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


Access Database Outside Appery

Posted: Fri Oct 23, 2015 6:46 pm
by Serhii Kulibaba

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


Access Database Outside Appery

Posted: Fri Oct 23, 2015 11:10 pm
by EJLD

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 ?


Access Database Outside Appery

Posted: Sat Oct 24, 2015 2:41 am
by Evgene Karachevtsev

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 :)


Access Database Outside Appery

Posted: Sun Nov 29, 2015 1:31 pm
by EJLD

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


Access Database Outside Appery

Posted: Tue Dec 01, 2015 7:11 pm
by Serhii Kulibaba

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