1

I need to extract a part of a header field from the response. I used the debug() function to see what the data looks like. For some reason, this error always pops up:

`Cannot read property 'content-disposition' of undefined`

What am I doing wrong? debug(data) returning:

[
  {
    "cache-control": "no-cache, private",
    "content-disposition": "attachment; filename=\"693-200x300.bmp\"",
    "content-type": "image/x-ms-bmp; charset=binary",
    "date": "Wed, 29 Jul 2020 14:12:54 GMT"
  }
]
function getName(data) {
  debug(data);
  if (data && data[0]["content-disposition"])
    return data[0]["content-disposition"].split('"')[1]
  return "function getName input data invalid";
}

0 Answers0