Skip to content

How get body of the request from fetch of a json data #1

@vespadj

Description

@vespadj

Please, provide an example for getting the body of the request when using fetch method.

// request options
const options = {
    method: 'POST',
    body: JSON.stringify(myCustomData),
    headers: {
        'Content-Type': 'application/json'
    }
}

// send POST request
fetch(url, options)
    .then(res => res.json())
    .then(res => console.log(res));

I try

-- display all posted values
for name,value in request:datapairs() do
  print(name,'=',value)
end

but the result is empty.

ECMA6 Fetch function is explained here.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions