0.0.4 • Published 6 years ago

post-links v0.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

POST Links

Ever needed to open an URL by clicking a link or a button but without showing your precious query string parameters? Suffer no more my friend, for I am here to help!

How to

Just add a method="post" to a <a href="..."> element. Every data-property attribute will be passed as data for the request.

<a method="post" href="http://example.com/pdf/generate" data-secret-id="123910" data-name="PDF-NAME">
    Download the super secret PDF
</a>

You can also change the target="".

<a method="post" href="http://example.com/pdf/generate" data-secret-id="123910" target="_blank">
    Open in new tab the super secret PDF
</a>

How

post-links creates a hidden form with and submits it via POST everytime a <a method="post"> is clicked.

Methods

import PostLinks from 'post-links'

// Search for a click on all current and future <a method="post">
PostLinks.listen()

// Opens a URL programatically on `target` with the data on `dataObject`
PostLinks.open(url, (dataObject = {}), (target = ''))