Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
752bbd74b0 | |||
467f8d3254 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/webrequest",
|
"name": "@pushrocks/webrequest",
|
||||||
"version": "2.0.5",
|
"version": "2.0.6",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/webrequest",
|
"name": "@pushrocks/webrequest",
|
||||||
"version": "2.0.5",
|
"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",
|
||||||
|
@ -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: {
|
||||||
|
Reference in New Issue
Block a user