G
G
gudalexiji2019-02-18 20:13:16
Node.js
gudalexiji, 2019-02-18 20:13:16

How to make a simple POST request from Node?

I'm trying to send a regular POST with Node/Express and I'm getting a response:
No 'Access-Control-Allow-Origin' header is present on the requested resource.

const https = require('https');
const options = {
  hostname: 'connect.stripe.com',
  port: 443,
  path: '/oauth/token',
  method: 'POST',
  headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}

const req = https.request(
  options, res => 
    res.on('data', d => 
      process.stdout.write(d))
)
req.write(data) // client_secret=stripe_sk&grant_type=authorization_code...
req.end()

Can any other headers interfere at the Express level?
From Postman, everything exchanges perfectly.

Please tell me where to dig?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question