athombv / node-homey-oauth2app

This module does the heavy lifting for a Homey App that talks to any OAuth2 Web API.
https://athombv.github.io/node-homey-oauth2app/
5 stars 5 forks source link

fix: body not passed in request #27

Closed jeroenwienk closed 3 years ago

jeroenwienk commented 3 years ago
async sync() {
    const params = new URLSearchParams();
    params.append('token', this._token.access_token);
    params.append('sync_token', '*');
    params.append('resource_types', '["user"]');

    // node fetch will set content type to application/x-www-form-urlencoded
    // because of url search params 

    // body is never passed here
    console.log(
      await this.post({
        path: '/sync/v8/sync',
        body: params,
      })
    );

    // this works fine with locally installed node-fetch package
    return fetch('https://api.todoist.com/sync/v8/sync', {
      method: 'POST',
      body: params,
    })
      .then((res) => res.json())
      .then((json) => console.log(json));
  }
CLAassistant commented 3 years ago

CLA assistant check
All committers have signed the CLA.

WeeJeWel commented 3 years ago

I think it's more clear when opts.body is being set in the } else { of if( json ) {.