Answers for "send json response"

-1

node js return json

var http = require('http');

var app = http.createServer(function(req,res){
    res.setHeader('Content-Type', 'application/json');
    res.end(JSON.stringify({ a: 1 }));
});
app.listen(3000);

// > {"a":1}
Posted by: Guest on June-19-2020
2

send json body in get request

// please don't. use query or route params instead.
Posted by: Guest on July-15-2021
0

HTTPoison post json

url = "http://myurl"
body = Poison.encode!(%{
  "call": "MyCall",
  "app_key": key,
  "param": [
    %{
      "page": page,
      "registres": registers,
      "filter": filter
    }
  ]
})
headers = [{"Content-type", "application/json"}]
HTTPoison.post(url, body, headers, [])
Posted by: Guest on April-07-2021

Browse Popular Code Answers by Language