Swiss Army Knife Challenge Balance Platform
How to make an API call
- Duplicate "template.js". Add all json data here to be sent to the php file to make a call to the API endpoint
- Duplicate "template.php". Change the url to whichever endpoint you are sending the request to
- Get response back to your frontend js and do logic on response
See an example of this by going to [localhost]/apiCallExample.html
How to make a database call
- Follow the same process to make a server call (i.e callServer()) with the url as dbQuery.php
- Pass an SQL Query through to dbQuery which will execute the dbQuery and return:
- A JSON of search results from a SELECT db query
- Log out an empty error message and return a false. Use this false to handle login where you were expecting a result. A good example of this is in the registration.js/login.js files where if we receive a false response we can either add a new user or prevent login
See an example of this by going to [localhost]/apiCallExample.html => Do Database Query
FYI: The dbConnection.php has the database connection logic in it - no need to touch this. The dbQuery.php has the database call login in it - also no need to touch this.