Home  >  Q&A  >  body text

Add the Endpoint _header attribute to the JSON response object

I'm testing pulling data from a remote endpoint service (npoint.io). When I get back the response object, it adds the "_headers" attribute to my JSON.

I guess I can remove this attribute when I stringify the JSON. But asking because maybe I'm missing an optional parameter in http.get() that I should use to remove it.

First, here is the response from the server:

{
    "schema": {
        "type": "object",
        "title": "Simple Test",
        "required": [],
        "properties": {}
    },
    "data": {},
    "_headers": {
        "cache-control": "max-age=0, private, must-revalidate",
        "content-type": "application/json; charset=utf-8"
    }
}

I look forward to:

{
    "schema": {
        "type": "object",
        "title": "Simple Test",
        "required": [],
        "properties": {}
    },
    "data": {}
}

P粉237689596P粉237689596177 days ago1381

reply all(1)I'll reply

  • P粉587970021

    P粉5879700212024-04-06 00:58:08

    I haven't looked into the API documentation for npoint.io, maybe you can add a query parameter to get rid of it?

    I think they are just trying to be "friendly" by repeating the headers they set for the response in JSON. Although somewhat unnecessary since you can read the response headers directly in JS if you wanted to...

    I would ignore it and remove the attribute, it's not an overhead in bytes :)

    reply
    0
  • Cancelreply