POSTing with JSON using npm request

前端 未结 3 1509
生来不讨喜
生来不讨喜 2021-02-20 11:04

How would one do the following with the request npm module?

curl https://todoist.com/oauth/access_token \\
    -d client_id=0123456789abcdef \\
             


        
3条回答
  •  难免孤独
    2021-02-20 11:43

    const formData = {
       client_id:     '0123456789abcdef', 
       client_secret: 'secret', 
       code:          'abcdef'
    };
    
    request.post(
      {
        url: 'https://todoist.com/oauth/access_token',
        form: formData
      },
      function (err, httpResponse, body) {
        console.log(err, body);
      }
    );
    

    Please try this code.

提交回复
热议问题