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));
}