Skip to content
Open links using POST instead of GET
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
src
test
.eslintrc
README.MD
package-lock.json
package.json

README.MD

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 = ''))
You can’t perform that action at this time.