Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rest api instead of sql statements. #Hacktoberfest #23

Open
agnelvishal opened this issue Oct 22, 2018 · 8 comments
Open

Use rest api instead of sql statements. #Hacktoberfest #23

agnelvishal opened this issue Oct 22, 2018 · 8 comments

Comments

@agnelvishal
Copy link
Owner

As of now, mysql query is used in the php file to interact with the database. A rest api is available but has not been used in the php file. Could someone help?

@agnelvishal
Copy link
Owner Author

The rest api is available at https://github.com/agnelvishal/Condense.press/tree/master/rest-api

@devdadmax
Copy link

pull request has been submitted.

@agnelvishal
Copy link
Owner Author

Hello @LegacyStackCrash Will it be possible to use ajax instead of curl?

@devdadmax
Copy link

@agnelvishal it is possible to produce the same functionality using ajax instead of curl. However I would highly recommend a small refactor if you want to move over to ajax. Additionally some other things to consider is that by moving to an AJAX call you will now be subject to CORS. While this is not an issue when your client and server are on the same host. It can become a little confusing if you choose to serve your server from say "example.com" but then serve your client page from "example2.com".

@agnelvishal
Copy link
Owner Author

By refactor, is it meant that the code for high charts and cards have to be moved from server to client?

@devdadmax
Copy link

In this case that is correct. Currently your HTML and JS is intertwined with your PHP which is okay for the approach for the way it currently works. However you would not really want to leave the extra overhead of PHP on the client side rendering if you are going to utilize ajax to request the data from the front end.

@agnelvishal
Copy link
Owner Author

So in this case ajax is a bad idea?

@devdadmax
Copy link

devdadmax commented Oct 23, 2018

Not necessarily, this is more or less a design decision on your part to determine if you would prefer your server to do the work on gathering data or if you want your client's browser to do the work to gather the data. However if you want to move to your client gathering data(ajax) a small refactor(code rewrite) would be beneficial to your project as you gain no benefit from your db.php once you move to using an Ajax call.

I see that you also have an issue open for refactoring to VueJS. When this issue is picked up would be a good time to refactor the way your client is served content from curl to an ajax call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants