Add the Endpoint _header attribute to the JSON response object
P粉237689596
P粉237689596 2024-04-05 10:35:39
0
1
1380

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粉237689596
P粉237689596

reply all(1)
P粉587970021

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 :)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!