Skip to content

Instantly share code, notes, and snippets.

@MonteLogic
Last active September 20, 2023 19:10
Show Gist options
  • Save MonteLogic/508cfe05aaa1f0d20ccf08c461fe15a7 to your computer and use it in GitHub Desktop.
Save MonteLogic/508cfe05aaa1f0d20ccf08c461fe15a7 to your computer and use it in GitHub Desktop.
import axios from 'axios';
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-call */
import { PrismaClient } from '@prisma/client';
// So apparently I need to keep this line or else it would be undefined. I don't know why this line work to have env variables but it just does.
const prisma = new PrismaClient();
export const accountSid: string | undefined = process.env.accountSid;
console.log(accountSid);
export {};
const postData = {
ToCountry: 'US',
ToState: 'CA',
SmsMessageSid: 'SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
NumMedia: '0',
ToCity: 'Los Angeles',
FromZip: '94107',
SmsSid: 'SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
FromState: 'CA',
SmsStatus: 'received',
FromCity: 'San Francisco',
Body: 'Hello from Twilio!',
FromCountry: 'US',
To: '+1415XXXXXXX',
ToZip: '90012',
NumSegments: '1',
MessageSid: 'SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
AccountSid: 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
From: '+1415XXXXXXX',
ApiVersion: '2010-04-01',
};
const localURL = `${process.env.localURL ?? 'http://localhost:3000/'}/api/receive-texts`;
axios
.post(localURL, postData, {
headers: {
'Content-Type': 'application/json',
},
})
.then(response => {
// Handle the response from the server
console.log(response.data);
})
.catch(error => {
// Handle any errors that occurred during the request
console.error('Error:', error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment