Socket
Socket
Sign inDemoInstall

wpcom-xhr-request

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wpcom-xhr-request

REST API requests to WordPress.com via XMLHttpRequest (and CORS)


Version published
Weekly downloads
605
decreased by-12.32%
Maintainers
2
Weekly downloads
 
Created
Source

wpcom-xhr-request

REST API requests to WordPress.com via XMLHttpRequest (and CORS)

You likely want to use the high-level APIs in wpcom.js instead of using this module directly.

Works in both the browser and Node.js via superagent.

Installation

Install wpcom-xhr-request using npm:

$ npm install wpcom-xhr-request

Example

<html>
  <body>
    <script src="wpcom-xhr-request.js"></script>
    <script>
      WPCOM.xhr('/me', function(err, res){
        if (err) throw err;

        var div = document.createElement('div');
        div.innerHTML = 'Your WordPress.com "username" is: <b>@' + res.username + '<\/b>';
        document.body.appendChild(div);
      });
    </script>
  </body>
</html>

Authentication

For API requests that require authentication to WordPress.com, you must pass in an OAuth token as the authToken parameter in the params object for the API call.

You can get an OAuth token server-side through node-wpcom-oauth, or any other OAuth2 interaction mechanism.

License

MIT – Copyright Automattic 2014

Keywords

FAQs

Package last updated on 08 Jul 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc