screenshots-pagepixels
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -5,2 +5,6 @@ ## [Unreleased] | ||
- Initial release | ||
- Initial release | ||
## [1.0.1] - 2023-05-05 | ||
- Ensure access token is sent in querystring for get requests. |
{ | ||
"name": "screenshots-pagepixels", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Screenshots PagePixels is an NPM package that provides a simple and easy-to-use interface for working with the PagePixels API. With this package, you can easily capture screenshots, manage screenshot configurations, create recurring screenshot schedules, setup multi-step screenshots, and more. Screenshots PagePixels provides convenient methods that wrap around the API endpoints, making it easy to get started and integrate with your application.", | ||
@@ -5,0 +5,0 @@ "main": "screenshots-pagepixels-client.js", |
@@ -10,3 +10,3 @@ const http = require('http'); | ||
async request(method, path, options = {}, body = null) { | ||
async request(method, path, options = {}) { | ||
const url = new URL(this.apiBaseUrl + path); | ||
@@ -24,6 +24,16 @@ const isHttps = url.protocol === 'https:'; | ||
if (body) { | ||
let body = null; | ||
if (method !== 'GET') { | ||
requestOptions.headers['Content-Type'] = 'application/json'; | ||
body = JSON.stringify(body); | ||
body = JSON.stringify(options); | ||
requestOptions.headers['Content-Length'] = Buffer.byteLength(body); | ||
} else { | ||
// Convert options object to a query string | ||
const queryString = Object.entries(options) | ||
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`) | ||
.join('&'); | ||
if (queryString) { | ||
requestOptions.path += '?' + queryString+'&access_token='+this.bearerToken; | ||
} | ||
} | ||
@@ -39,3 +49,3 @@ | ||
if (res.statusCode >= 200 && res.statusCode < 300) { | ||
if (path === '/snap' && !options.json) { | ||
if (path === '/snap' && method === 'GET' && !options.json) { | ||
resolve(data); | ||
@@ -42,0 +52,0 @@ } else { |
20418
97