json - How to call HTTPS authentication using JavaScript -



json - How to call HTTPS authentication using JavaScript -

i wondering if help me coding need utilize on javascript(google script) authentication on https.

all requests must made on https. info sent , received json.

when making requests, receive info json setting take header application/json, shown in illustration below:

$ curl https://yoursite.desk.com/api/v2/cases/:id \ -u email:password \ -h 'accept: application/json'

this https authentication provided website api. , wondering if help calling using javascript.

thank you.

i've been unable test well, should work var ajax = function(url, user, pass, cb) { var xhr = new xmlhttprequest(); xhr.onreadystatechange = readyornot; function readyornot() { if (xhr.readystate < 4 || xhr.status !== 200) return; xhr.readystate === 4 && cb(xhr); } xhr.open('get', url, true, user, pass); xhr.send(); } then can like: var url ='http://some.thingy.biz/api/v2/:id'; ajax(url, 'myuser', 'mypass', function(data) { ... cool info stuff ... });

javascript json api curl header

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -