Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // makeRequest when data-Obj is transformed to string with JSON.stringify(data)
- // We need to append: contentType: 'application/json'
- function makeRequest(method, module, endpoint, auth) {
- return {
- url: BASE_URL + module + '/' + APP_KEY + '/' + endpoint,
- method: method,
- headers: {
- 'Authorization': makeAuth(auth)
- },
- contentType: 'application/json'
- }
- }
- // post function when data-Obj is transformed to string with JSON.stringify(data)
- function post(module, endpoint, auth, data) {
- let obj = makeRequest('POST', module, endpoint, auth);
- if (data) {
- obj.data = JSON.stringify(data);
- }
- return $.ajax(obj);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement