IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
735B

  1. makeArvadosRequest(arvHost, arvToken, endpoint, method='GET', data=null,
  2. contentType='application/json;charset=utf-8', responseType='json') {
  3. let xhr = new XMLHttpRequest();
  4. xhr.open(method, 'https://' + arvHost + endpoint);
  5. xhr.setRequestHeader('Authorization', 'OAuth2 ' + arvToken);
  6. if (data !== null)
  7. xhr.setRequestHeader('Content-Type', contentType);
  8. xhr.responseType = responseType;
  9. let res = new Promise((accept, reject) => {
  10. xhr.onreadystatechange = () => {
  11. if (xhr.readyState !== 4)
  12. return;
  13. if (xhr.status !== 200)
  14. reject(xhr);
  15. else
  16. accept(xhr);
  17. };
  18. xhr.send(data);
  19. });
  20. return res;
  21. }
  22. export default makeArvadosRequest;