Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP requests should be triggerable by HTTP verb methods or by promise syntax #6

Closed
kadamwhite opened this issue Jun 3, 2014 · 3 comments

Comments

@kadamwhite
Copy link
Collaborator

For maximum flexibility and convenience, both callback and promise-style syntax should be valid: This is the rationale for pulling in a Promise lib as per #2

// Callback-style
wp.posts().filter({ posts_per_page: 7 }).get(function(err, data) {
  if ( err ) {
    // handle error
  } else {
    // do something with data
  }
});

// Promise-style
wp.posts().filter({ posts_per_page: 7 }).then(function(data) {
  // do something with data
}, function(err) {
  // handle error
});

Additionally, if .then is called on a query chain, it assumes the GET method unless otherwise specified:

wp.posts().id(7).data(postObj).put().then(function(response) { /* ... */ });
@kadamwhite
Copy link
Collaborator Author

Speaking of verbs, here's an overview of PATCH

@kadamwhite
Copy link
Collaborator Author

The first part of this should be addressed by #12 : I'll open a separate issue for PATCH. Leaving this open pending code review; let me know if it's working for you.

@kadamwhite
Copy link
Collaborator Author

Closing in favor of #22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant