Skip to content

Commit

Permalink
fix: 🐛 accessing property that might not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
SophiaH67 committed Apr 4, 2024
1 parent 7debb24 commit aed3508
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/PrintOne.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,14 @@ export class PrintOne {
* Create an order
*/
public async createOrder(data: CreateOrder): Promise<Order> {
const templateId =
typeof data.template === "string" ? data.template : data.template.id;
let templateId: undefined | string;

if (data.template instanceof Template) {
templateId = data.template.id;
} else {
templateId = data.template;
}

const sendDateStr =
data.sendDate instanceof Date
? data.sendDate.toISOString()
Expand All @@ -266,8 +272,13 @@ export class PrintOne {
}

public async createCsvOrder(data: CreateCsvOrder): Promise<CsvOrder> {
const templateId =
typeof data.template === "string" ? data.template : data.template.id;
let templateId: undefined | string;

if (data.template instanceof Template) {
templateId = data.template.id;
} else {
templateId = data.template;
}

const formData = new FormData();
formData.append(
Expand Down

0 comments on commit aed3508

Please sign in to comment.