africaistalking
A promise-based API wrapper with cors enabled for africastalking
Install
npm i africaistalking --save
usage
Sending SMS
import africaistalking from 'africaistalking'const username='MyAppUsername'const message='Hello You!'const to='+254711XXXYYY,+254733YYYZZZ'const apikey='MyAppApiKey'const from="MyCompany" //optional parameter,check africastalking.com for documentation on how to use
Usage with Redux/redux-promise-middleware
Dispatch africaistalking API as the value of the payload property of the action.
import africaistalking from 'africaistalking'const sendMessage = username message to apikeytype: 'SEND_MESSAGE'payload:
A pending action is immediately dispatched.
type: 'SEND_MESSAGE_PENDING'
Once the promise is settled, a second action will be dispatched. If the promise is resolved a fulfilled action is dispatched.
type: 'SEND_MESSAGE_FULFILLED'payload:...
On the other hand, if the promise is rejected, a rejected action is dispatched.
type: 'SEND_MESSAGE_REJECTED'error: truepayload:...