smsir_mh_ts
Version:
This package is for using SMS service from sms.ir should get API and templetId from sms.ir. TypeScript support
31 lines (27 loc) • 811 B
text/typescript
import axios, { AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios';
export const SendAlertSMSIR = (to: string, message: string, api_key: string, templateId: string): void => {
const data = JSON.stringify({
"mobile": to,
"templateId": templateId,
"parameters": [
{ name: 'CONTACTS', value: message }
],
});
const config: AxiosRequestConfig = {
method: 'post',
url: 'https://api.sms.ir/v1/send/verify',
headers: {
'Content-Type': 'application/json',
'Accept': 'text/plain',
'X-API-KEY': api_key
},
data: data
};
axios(config)
.then((response: AxiosResponse) => {
console.info(JSON.stringify(response.data));
})
.catch((error: AxiosError) => {
console.error(error);
});
};