API - Basic API calls

look at those 2 functions "put" and "delete". They are very similar.

I want you to think of a very generic function which could be reused for almost any API request. You are doing almost the same thing over and over again.

The difference is SQL being executed, access level, id which might need to be checked for existence, callback which is called possibly with array of returned results from the queryDB.

Try to refactor those 2 functions to use this generic one.