Spiel request is a module to send ajax request. It use XmlHttpRequest
import {httpRequest, RequestConfig, RequestOptions, Headers} from 'spiel-request'
const headers: Headers = {
'Accept': 'application/json, text/*'
}
const options: RequestConfig = {
responseType: 'text',
headers,
credentials: true,
authType: 'base64',
auth: {
username: 'test'
password: '123456'
}
domain: 'http://localhost:3000'
}
const url = 'http://localhost:3000/users';
const response = httpRequest.sendRequest({
url,
method: 'get'
});
const url = 'http://localhost:3000/upload';
const blob = new Blob(['abc123'], {type: 'text/plain'});
const file = httpRequest.uploadFile({
url,
file: blob,
responseType: 'json',
name: 'test'
});
const oReq = httpRequest.request
oReq.addEventListener("progress", updateProgress);
oReq.addEventListener("load", transferComplete);
oReq.addEventListener("error", transferFailed);
oReq.addEventListener("abort", transferCanceled);
oReq.open();
Open two terminals, in the first execute npm run service
and the another npm test
Spiel Request is MIT licensed. See license
Generated using TypeDoc