LITE & EASY Elastic Email API Wrapper with ES 2015 Promises.
npm install elastic-email-promiseThis LITE Wrapper, allows you to quickly and easily use the Elastic Email API v2 via Node.js and with ES 2015 Promises.



js
npm i elastic-email-promise
`
__Set up your client:__
`js
const ee = require( 'elastic-email-promise' );
const eeClient = ee.Client( { apikey: 'Your Apikey' } );
`
__request method with only api key required:__
`js
eeClient.request( '/account/load' )
.then( function( data ) { console.log( data ) } )
.catch( function( error ) { console.log( error ) } );
`
__request method with more parameters:__
`js
eeClient.request( '/contact/findcontact', { email: 'example@example.com' } )
.then( function( data ) { console.log( data ) } )
.catch( function( error ) { console.log( error.message ) } )
`
__request method with file upload:__
`js
const fs = require('fs');
eeClient.request( '/contact/upload', {
contactFile: fs.createReadStream('CSV_Sample1.csv')
})
.then( function( data ) { console.log( data ) } )
.catch( function( error ) { console.log( error.message ) } )
`
$3
`js
eepromise.request( 'path', { params } );
`
__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:
`js
//On success
{success: true, data: / response data it could be array or object /}
//On false
{success: false, error: 'error message as string'}
``