Skip to content

Commit

Permalink
Fix Undefined Error in certain methods (#154)
Browse files Browse the repository at this point in the history
Fix "Failed to convert JavaScript value `Undefined` into rust type `String`" Error in certain methods using .toBuffer()
  • Loading branch information
21Z authored May 11, 2023
1 parent 8dd1c64 commit 3121bba
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Canvacord.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class Canvacord {
rect(ctx, track.x, track.y, track.height, bar.width, bar.color, false);
}

return canvas.toBuffer();
return canvas.toBuffer("image/png");
}

/**
Expand Down Expand Up @@ -249,7 +249,7 @@ class Canvacord {
ctx.fillText(color.toUpperCase(), canvas.width / 3, canvas.height / 2);
}

return canvas.toBuffer();
return canvas.toBuffer("image/png");
}

/**
Expand Down Expand Up @@ -283,7 +283,7 @@ class Canvacord {
const ctx = canvas.getContext("2d");
rect(ctx, x, y, canvas.height, canvas.width, color, !!stroke, lineWidth);
round(ctx, x, y, canvas.width, canvas.height);
return canvas.toBuffer();
return canvas.toBuffer("image/png");
}

/**
Expand Down Expand Up @@ -799,7 +799,7 @@ class Canvacord {
fill[x] === "X" ? drawX(data.x, data.y) : drawO(data.x, data.y);
});

return canvas.toBuffer();
return canvas.toBuffer("image/png");
}

/**
Expand Down Expand Up @@ -850,7 +850,7 @@ class Canvacord {
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, canvas.width, canvas.height);

return canvas.toBuffer();
return canvas.toBuffer("image/png");
}

/**
Expand Down

0 comments on commit 3121bba

Please sign in to comment.