Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sendgrid] - minor bug preventing dynamic field from working #2591

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
GET_GROUP_IDS_URL,
GET_TEMPLATE_CONTENT_URL
} from './constants'
import { parseTemplateId } from './utils'

interface ResultError {
response: {
Expand Down Expand Up @@ -51,8 +52,14 @@ export async function dynamicTemplateData(request: RequestClient, payload: Paylo
throw new Error('Template ID Field required before Dynamic Template Data fields can be configured')
}

const templateId = parseTemplateId(payload.template_id ?? '')

if (templateId == null || !templateId.startsWith('d-')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should there be an additional || templateId === '' here?

throw new Error('Template must refer to a Dynamic Template. Dynamic Template IDs start with "d-"')
}

try {
const response: ResponseType = await request(`${GET_TEMPLATE_CONTENT_URL}${payload.template_id}`, {
const response: ResponseType = await request(`${GET_TEMPLATE_CONTENT_URL}${templateId}`, {
method: 'GET',
skipResponseCloning: true
})
Expand Down
Loading