Rendering a Base64 PNG with Express

后端 未结 3 1381
小鲜肉
小鲜肉 2020-12-08 11:02

My Node.js server has something that looks like the following:

app.get(\"/api/id/:w\", function(req, res) {
    var data = getIcon(req.params.w);
});
         


        
3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-08 11:12

    I had to do a bit of manipulation first to get mine in the right format, but this worked great:

      var base64Data = data.replace(/^data:image\/png;base64,/, '');
    

提交回复
热议问题