Skip to content

Commit

Permalink
fix url
Browse files Browse the repository at this point in the history
  • Loading branch information
jakehobbs committed Jun 21, 2024
1 parent 6612fa0 commit 259ba41
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions components/HomePage/Letter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ import ReCAPTCHA from "react-google-recaptcha";

const PETITION_API_URL = "https://petitions-229503.appspot.com/api/sign";

const CAMPAIGN_MAILER_API_URL = `${
const CAMPAIGN_MAILER_API_URL =
process.env.NODE_ENV === "production"
? "https://helptheducks.dxe.io"
: "http://localhost:3333"
}/message/create`;
: "http://localhost:3333";

declare global {
interface Window {
Expand Down Expand Up @@ -145,22 +144,25 @@ export const LetterForm = (props: { afterSubmit?: () => void }) => {
alert("Error submitting. Please try again.");
throw new Error("Error submitting petition");
}
const campaignMailerResp = await ky.post(CAMPAIGN_MAILER_API_URL, {
json: {
name: data.name,
email: data.email,
...(data.phone && { phone: data.phone }),
outside_us: data.outsideUS,
...(data.zip && { zip: data.zip }),
message: data.message,
campaign: CAMPAIGN,
token,
},
headers: {
"Content-Type": "application/json",
},
throwHttpErrors: false,
});
const campaignMailerResp = await ky.post(
`${CAMPAIGN_MAILER_API_URL}/message/create`,
{
json: {
name: data.name,
email: data.email,
...(data.phone && { phone: data.phone }),
outside_us: data.outsideUS,
...(data.zip && { zip: data.zip }),
message: data.message,
campaign: CAMPAIGN,
token,
},
headers: {
"Content-Type": "application/json",
},
throwHttpErrors: false,
}
);
if (campaignMailerResp.status !== 200) {
setIsSubmitting(false);
alert("Error submitting. Please try again.");
Expand Down

0 comments on commit 259ba41

Please sign in to comment.