Compare commits

...

5 Commits

Author SHA1 Message Date
752bbd74b0 2.0.6 2019-09-27 21:20:06 +02:00
467f8d3254 fix(core): update 2019-09-27 21:20:06 +02:00
9ff7713103 2.0.5 2019-09-27 20:44:43 +02:00
30de4add37 2.0.4 2019-09-27 20:16:29 +02:00
434dbd718a fix(core): update 2019-09-27 20:16:28 +02:00
6 changed files with 61 additions and 6 deletions

29
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,29 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
}
]
}

20
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,20 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone"
}
}
}
}
]
}

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/webrequest", "name": "@pushrocks/webrequest",
"version": "2.0.3", "version": "2.0.6",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/webrequest", "name": "@pushrocks/webrequest",
"version": "2.0.3", "version": "2.0.6",
"private": false, "private": false,
"description": "securely request from browsers", "description": "securely request from browsers",
"main": "dist/index.js", "main": "dist/index.js",

View File

@ -60,11 +60,17 @@ tap.test('first test', async tools => {
'http://localhost:2345/apiroute3' 'http://localhost:2345/apiroute3'
]); ]);
const response2 = await new webrequest.WebRequest().getJson('http://localhost:2345/apiroute3');
console.log(response); console.log(response);
console.log(response2)
expect(response) expect(response)
.property('hithere') .property('hithere')
.to.equal('hi'); .to.equal('hi');
expect(response2)
.property('hithere')
.to.equal('hi');
}); });
tap.test('tear down server', async () => { tap.test('tear down server', async () => {

View File

@ -16,7 +16,7 @@ export class WebRequest {
*/ */
public async postJson(urlArg: string, requestBody?: any) { public async postJson(urlArg: string, requestBody?: any) {
const response: Response = await this.request(urlArg, { const response: Response = await this.request(urlArg, {
body: requestBody, body: JSON.stringify(requestBody),
method: 'POST' method: 'POST'
}); });
return response.json(); return response.json();
@ -27,7 +27,7 @@ export class WebRequest {
*/ */
public async putJson(urlArg: string, requestBody?: any) { public async putJson(urlArg: string, requestBody?: any) {
const response: Response = await this.request(urlArg, { const response: Response = await this.request(urlArg, {
body: requestBody, body: JSON.stringify(requestBody),
method: 'PUT' method: 'PUT'
}); });
return response.json(); return response.json();
@ -89,7 +89,7 @@ export class WebRequest {
if (!urlToUse) { if (!urlToUse) {
throw new Error('request failed permanently'); throw new Error('request failed permanently');
} }
console.log(`Getting ${urlToUse} with method ${optionsArg.method}`);
const response = await fetch(urlToUse, { const response = await fetch(urlToUse, {
method: optionsArg.method, method: optionsArg.method,
headers: { headers: {
@ -108,7 +108,7 @@ export class WebRequest {
} }
}; };
const finalResponse: Response = await doRequest(urlArg[usedUrlIndex]); const finalResponse: Response = await doRequest(allUrls[usedUrlIndex]);
console.log(finalResponse); console.log(finalResponse);
return finalResponse; return finalResponse;
} }