import SDKMeta from "NatyMeta"
The API URL for the integration with the Meta API. The default value is https://api.meta.naty.app
API_META=https://api.meta.naty.app
const SDK = new NatyMeta()
// you can use new sdk(`YOUR-APP-TOKEN`) to connect right on the class creation
const connectSDK = await SDK.connect( {apptoken: { `YOUR-APP-TOKEN` } } )
if(connectSDK.isError) throw new Error(connectSDK.isError.message)
console.log(connectSDK.isSuccess)
// Do what you need with the data... (connectSDK.isSuccess)
SDK.on('message', (res) => {
res.sendTextMessage("teste");
});
- Retun of any Promise is {isSuccess:AuthReturnType, isError:ErrorHandlingType}
- If successed method (like the SDK.connect example too),
the sdk will abstract and will handle properly with the token for you,
the token will be automatic joined into axios instance header - ErrorHandling type { code: number, message: string | Object }
- On the exemple, we are using "throw new Error" on every ErrorHandling to
stop and handle it on a simple way, but u can work at your way like
returning an alert using some alert lib like toastfy for the user.