Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const baseUrl = 'https://baas.kinvey.com/';
- const appKey = 'kid_BJz94Cj1N';
- const appSecret = 'aa1c91c934994554ae791884e07b2391';
- function makeAuth(type) {
- return type === 'basic'
- ? 'Basic ' + btoa(appKey + ':' + appSecret)
- : 'Kinvey ' + sessionStorage.getItem('authtoken');
- }
- function makeRequest(method, module, url, auth) {
- return req = {
- method,
- url: baseUrl + module + '/' + appKey + '/' + url,
- headers: {
- Authorization: makeAuth(auth)
- }
- };
- }
- function post(module, url, data, auth) {
- let req = makeRequest('POST', module, url, auth);
- req.data = JSON.stringify(data);
- req.headers['Content-Type'] = 'application/json';
- return $.ajax(req);
- }
- let form = $('#formRegister');
- let username = form.find('input[name="username"]').val();
- let password = form.find('input[name="passwd"]').val();
- let userInfo = await requester.post('user', '', {username, password},'basic');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement