This LITE Wrapper, allows you to quickly and easily use the Elastic Email API v2 via Node.js and with ES 2015 Promises.
Quick Examples:
Install:
npm i elastic-email-promise
Set up your client:
const ee = ;const eeClient = ee;
request method with only api key required:
eeClient ;
request method with more parameters:
eeClient
request method with file upload:
const fs = ; eeClient
Request method:
eepromise;
path : string; path for method (f.e. "/channel/list") params: object; parameters for method return => Promise Object with respond
More information about EE Api methods you can find in EE API Documentation
How does elastic-email-promise pass Elastic Email response?
Elastic Email API (version 2) response dosen't have correct HTTP status code. All responses are JSON string:
//On successsuccess: true data: /* response data it could be array or object *///On falsesuccess: false error: 'error message as string'
- Elastic Email Promise will try parse response to JSON.
- If something goes wrong, the exception be thrown to Promise reject
- Then JSON success parameter will be check.
- If true: resolve( data );
- If false: reject( new Error( error ) );