Connecting with MySQL database

Hi,

I’m very much new to app development. I do have experience of PHP, MySQL and web application development. I also know mid level Java and C#.

How can I use Fuse tool to connect to MySQL database. To begin with, I want to create a simple Login form to validate the user. How can I do that?

Any lead will be appraciated.

Best, Adil

Then you will send your form data using the fetch api to your server and connect to mysql serverside. Almost like you would send data from a html form. It’s probably easiest to receive it as json or xml in your PHP application.

Thanks Anders,

I’ve been able to use fetch api to connect to server and retrive a json encoded string. I can print that on screen using;

data.value = JSON.stringify(responseObject); and then <Text Value="{data} />

The result is something like this:

{"user_details": [{"user_id":"3920","user_name":"Adil Raza ....}

How can I retrieve individual items i.e. user_id from this string?

Regards, Adil

Your responseObject contains the key user_details, whose value is an array of objects.

For instance, to get the user_id of the first user in the array, you can write:

data.value = responseObject.user_details[0].user_id;

Nice :slight_smile:

I think this example is almost what you want to do https://www.fusetools.com/examples/news-feed

This is great! Awsome.

How can I add the result to an Observable so that I can print that in app using Each tag? I tried looping over the array and add() using data.add(responseObject.user_detail[i]) but it throw OnAdd excpetion.

Thanks! I got it. :slight_smile:

Is there any example to use fetch to connect to my MySQL server I am new using fusetool

I assume you want to fetch data from a remote MySQL server? In that case, you need some sort of server-side code to provide an API that the app can connect to (just like with any other app framework).

I am getting code JSON of a API REST this is a URL whitout file JSON like this:
http://digg.com/api/news/popular.json

my API REST is like this:
http://api.portal.com/cover-last/
this return a code JSON.
I am using this on your example of Newsfeed just changing values, but this dont get nothing, the changes are this:

                    function Article(item) {
		this.title = item.data.first_title;
		this.description = item.data.short_description;
		this.author = item.data.edited_slug;
		this.published = new Date(item.data.created_at * 1000).toDateString();
		this.image = "";
		if (item.data.main_image.length > 0) this.image = 'http://www.portal.com/files/article_main/uploads/'+item.data.main_image.upload_prefix+'/'+item.data.main_image.image_name;
	};
	fetch("http://api.portal.com/cover-last/")
	.then(function(response) {  data="Hola";})
	.then(function(responseObject) {			
		for (var i in responseObject.thirdFold) {
			items.push(new Article(responseObject.thirdFold[i]));
		}
		data.replaceAll(items);			
	});

Plase you can help me?
What is the problem on this example?

@memofer_prof prefer making new forum posts over resurrecting old ones, which by the way are unrelated.

As for the problem, the URL you’re using can not be reached. I wouldn’t expect anything to happen if my API doesn’t respond.