Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query Params in POST request #175

Open
sergejs-katusenoks opened this issue Aug 27, 2021 · 0 comments
Open

Query Params in POST request #175

sergejs-katusenoks opened this issue Aug 27, 2021 · 0 comments

Comments

@sergejs-katusenoks
Copy link

I could not find in documentation if there is a way to use query params in POST request.

Proposal:

If params are present in POST request, then return them in response. This will allow to test POST request for the applications like proxy.

Example request:

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "title": "foo",
  "body": "bar",
  "userId": 1
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://jsonplaceholder.typicode.com/posts?someParam=someValue&anotherParam=anotherValue", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Example response:

{
    "title": "foo",
    "body": "bar",
    "userId": 1,
    "id": 101,
    "params": {
        "someParam": "someValue",
        "anotherParam": "anotherValue"
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant