Skip to main content

pdfshift@1.0.0

request(method, path, body, options)

This adaptor exports the following from common:

as()
assert()
combine()
cursor()
dataPath()
dataValue()
dateFns
each()
field()
fields()
fn()
fnIf()
group()
lastReferenceValue()
map()
merge()
scrubEmojis()
sourceValue()
util

Functions

request

request(method, path, body, options) ⇒ Operation

Make a general HTTP request to PDFShift

ParamTypeDescription
methodstringHTTP method to use
pathstringPath to resource
bodyBodyOptionsObject which will be attached to the POST body
optionsRequestOptionsOptional request options

This operation writes the following keys to state:

State KeyDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

Example: Make a request to convert a HTML string to PDF

request(
'POST',
'/convert/pdf',
{ source: $.html }
);

Interfaces

BodyOptions

PDF Body Options object. See PDFShift documentation for more details.

Properties

NameTypeDescription
sourcestringThe HTML string or url to convert to PDF.
sandboxbooleanGenerates PDF documents in dev mode that doesn't count in the credits.
encodebooleanReturn the generated PDF in Base64 encoded format, instead of raw. Defaults to true

HttpState

State object

Properties

NameDescription
datathe parsed response body
responsethe response from the HTTP server, including headers, statusCode, body, etc
referencesan array of all previous data objects used in the Job

PDFBodyOptions

PDF Body Options object. See PDFShift documentation for more details.

Properties

NameTypeDescription
sandboxbooleanGenerates PDF documents in dev mode that doesn't count in the credits.
encodebooleanReturn the generated PDF in Base64 encoded format, instead of raw. Defaults to true.

RequestOptions

Options provided to the HTTP request

Properties

NameTypeDescription
bodyobject | stringbody data to append to the request. JSON will be converted to a string (but a content-type header will not be attached to the request).
errorsobjectMap of errorCodes -> error messages, ie, { 404: 'Resource not found;' }. Pass false to suppress errors for this code.
formobjectPass a JSON object to be serialised into a multipart HTML form (as FormData) in the body.
queryobjectAn object of query parameters to be encoded into the URL.
headersobjectAn object of headers to append to the request.
parseAsstringParse the response body as json, text or stream. By default will use the response headers.
timeoutnumberRequest timeout in ms. Default: 300 seconds.
tlsobjectTLS/SSL authentication options. See https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions