9

I want to pass body parameters as shown in screen shot here (in text/plain format)

I am using axios in my nodejs/express project . My reqeust format is as shown below:

var config = { headers: { 'Content-Length': 0, 'Content-Type': 'text/plain' } }; const testInput = (req, res) => { axios.post('https://api.sandbox.xyz.com/v1/order/new', { firstName: 'Marlon' }, config) .then(function(response) { console.log('saved successfully') }) .catch(function(error) { console.log(error); }); }; 

For this how can I pass the body parameters appropriately?

3
  • 1
    What exactly is the problem? It looks fine to me Commented Jul 26, 2017 at 5:42
  • I want to pass { "request": "/v1/order/new", "nonce": 123457, "client_order_id": "20150102-4738721", "symbol": "btcusd", "amount": "34.12", "price": "622.13", "side": "buy", "type": "exchange limit" } as body parameter, how would I do that? Commented Jul 26, 2017 at 5:54
  • Instead of { firstName: '...' } you use that object you just posted? Commented Jul 26, 2017 at 5:56

1 Answer 1

16
var config = { headers: { 'Content-Length': 0, 'Content-Type': 'text/plain' }, responseType: 'text' }; 
  1. responseType indicates the type of data that the server will respond with
  2. options are arraybuffer , blob , document, json , text, stream
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.