Skip to content

kaisermann/post-links

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 = ''))

About

Open links using POST instead of GET

Resources

Stars

Watchers

Forks

Packages

No packages published