From db49e41727582e2b57e6ee33bec318ceee78a2ce Mon Sep 17 00:00:00 2001 From: Alanscut Date: Mon, 12 Oct 2020 20:51:04 +0800 Subject: [PATCH] fix undefined error when opts is undefined --- lib/server.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/server.js b/lib/server.js index ab72b21c..619e398e 100644 --- a/lib/server.js +++ b/lib/server.js @@ -92,7 +92,8 @@ exports.toCanvas = require('./browser').toCanvas exports.toString = function toString (text, opts, cb) { const params = checkParams(text, opts, cb) - const renderer = getStringRendererFromType(params.opts.type) + const type = params.opts ? params.opts.type : undefined + const renderer = getStringRendererFromType(type) return render(renderer.render, text, params) }