
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Some utility functions we use for several projects
See the CHANGELOG.md for information on what's new and what changed.
httpRequest(options)
Executes an HTTP request.
options
request options. See request
options documentationrequest
response
object, unless options.returnBody
is set to true
, in that case, it resolves
the promise with the body content.In the case where the request returns an HTTP error (anything from 400 to 599
HTTP status code), it will reject the promise with an error object with
err.message
= IncomingMessage.statusMessage
as it's message, and
err.statusCode
= IncomingMessage.statusCode
. If options.returnBody
is set
to false
, the err
object returned is augmented with the response object.
postJSONObject(url, objToSend, timeout, returnBody=true)
postJSON
, too.Sends a JSON object to and endpoint as an HTTP POST
url
URL string of the endpointobjToSend
object to sendtimeout
integer containing the number of milliseconds to
wait for a server to send response headers (and start the response body)
before aborting the request. Note that if the underlying TCP connection
cannot be established, the OS-wide TCP connection timeout will overrule the
timeout option (the default in Linux can be anywhere from 20-120 seconds).returnBody
boolean that defaults to true
. Instructs the function to return
body if true, or the response object response if false.request
response
body, unless returnBody
is set to false
, in that case, it resolves
the promise with the response object.In the case where the request returns an HTTP error (anything from 400 to 599
HTTP status code), it will reject the promise with an error object with
err.message
= IncomingMessage.statusMessage
as it's message, and
err.statusCode
= IncomingMessage.statusCode
.
If returnBody
is set to false
, the err
object returned is augmented with
the response object.
getJSON(url, timeout, returnBody = true)
Get a JSON object from an endpoint as an HTTP GET
url
URL string of the endpointtimeout
integer containing the number of milliseconds to
wait for a server to send response headers (and start the response body)
before aborting the request. Note that if the underlying TCP connection
cannot be established, the OS-wide TCP connection timeout will overrule the
timeout option (the default in Linux can be anywhere from 20-120 seconds).returnBody
boolean that defaults to true
. Instructs the function to return
body if true, or the response object response if false.request
response
body, unless returnBody
is set to false
, in that case, it resolves
the promise with the response object.In the case where the request returns an HTTP error (anything from 400 to 599
HTTP status code), it will reject the promise with an error object with
err.message
= IncomingMessage.statusMessage
as it's message, and
err.statusCode
= IncomingMessage.statusCode
.
If returnBody
is set to false
, the err
object returned is augmented with
the response object.
MIT © 2014-2022 Twenty20 Solutions
This module is free and open-source under the MIT License.
FAQs
PetroCloud Utils
We found that pcutils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.