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

Support JSON requests (GET & POST) #6

neocotic opened this issue Nov 23, 2016 · 2 comments


None yet
1 participant
Copy link

commented Nov 23, 2016

No description provided.

@neocotic neocotic modified the milestone: 2.1.0 Nov 24, 2016

neocotic pushed a commit that referenced this issue Nov 24, 2016

@neocotic neocotic referenced this issue Nov 24, 2016


2.1.0 #7

1 of 1 task complete

@neocotic neocotic self-assigned this Nov 24, 2016


This comment has been minimized.

Copy link
Owner Author

commented Nov 24, 2016

I committed this change today so it should be included in the next release. I added the following to the docs which should cover how this has been supported:

IMPORTANT: When sending GET requests, by design, all information will be included in the URL of the request
This includes data as well as any credentials used to authenticate with the API. You have been warned.
This is unavoidable when sending requests in the JSONP format but, when using the JSON format, you can send POST
requests, which means that your data is sent inside the body of the request. Combine this with HTTPS and your data and
credentials cannot be sniffed over the network.

As you may have noticed; this method also accepts the following entirely optional options:

Option Description Default
format Format in which requests are sent "jsonp"
method HTTP method to be used for requests "GET"
// Does the same as specifying no options (i.e. using defaults)
yourls.connect('', null, {
  format: 'jsonp',
  method: 'GET'

// Best practice if you want to secure the data you're transmitting and you've setup CORS, if needed
yourls.connect('', {
  signature: '3002a61584'
}, {
  format: 'json',
  method: 'POST'

The following formats are supported with the corresponding HTTP methods:

Format HTTP Methods
json GET, POST
jsonp GET

IMPORTANT: The YOURLS server must be running version 1.5.1 or newer in order to send requests in the JSONP

The new method signature for yourls.connect is as follows:

yourls.connect(url[, credentials][, options])

This comment has been minimized.

Copy link
Owner Author

commented Mar 24, 2017

This change has been included in today's 2.1.0 release.

@neocotic neocotic closed this Mar 24, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.