最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Axios serving png image is giving broken image - Stack Overflow

programmeradmin11浏览0评论

I am using express as middle-ware api.A person hits my middle-ware , it hits some third party api and returns back the result. Its working fine for all other end points expect an get end point that creates an png and serves it. so under method returns response

   _execute = R.curry((reqFunction, req, res) => {
        reqFunction(req, res).
        then(r => {
          res.status(r.status).header(r.headers).send(r.data)
        }).
        catch(err => {
          res.status(err.response.status).header(err.headers).send(err.response.data)
        })
      });

and reqFunction is method like

  modelDiagram = (req, res) => {
    const headers = req.headers;
    const modelName = req.params['modelName'];
    const endPoint = this.modelDiagramEndPoint + '/' + modelName;
    return this.httpRequests.get(endPoint, headers);
  }

and httpRequests.get method is

  get = (endPoint, headers) => {
    let options = {
      method: 'GET',
      url: endPoint
    }
    options = this.addHeaders(headers, options);
    return this._send(options);
  }

and this._send is like

  _send = (options) => {
    return axios(options);
  };

the response if I directly hit from browser is like ``` �PNG

IHDRn��7Q� IDATx���oHk� ���D�ȥ|!H�DD�^)"k"n�̤$H�V뒻�Vж"�+��n-"�[��X

发布评论

评论列表(0)

  1. 暂无评论