Skip to content

Add info about http redirects #677

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

Merged
merged 2 commits into from
Oct 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions _includes/cloudcode/cloud-code-advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A simple GET request would look like:

```javascript
Parse.Cloud.httpRequest({
url: 'http://www.awesomewebsite.com/'
url: 'https://www.awesomewebsite.com/'
}).then(function(httpResponse) {
// success
console.log(httpResponse.text);
Expand All @@ -24,7 +24,7 @@ A GET request that specifies the port number would look like:

```javascript
Parse.Cloud.httpRequest({
url: 'http://www.awesomewebsite.com:8080/'
url: 'https://www.awesomewebsite.com:8080/'
}).then(function(httpResponse) {
console.log(httpResponse.text);
}, function(httpResponse) {
Expand All @@ -34,6 +34,19 @@ Parse.Cloud.httpRequest({

Valid port numbers are 80, 443, and all numbers from 1025 through 65535.

By default, `Parse.Cloud.httpRequest` does not follow redirects caused by HTTP 3xx response codes, the `followRedirects: true` option can be used to change this.

```javascript
Parse.Cloud.httpRequest({
url: 'https://www.awesomewebsite.com/',
followRedirects: true
}).then(function(httpResponse) {
console.log(httpResponse.text);
}, function(httpResponse) {
console.error('Request failed with response code ' + httpResponse.status);
});
```

### Query Parameters

You can specify query parameters to append to the end of the url by setting `params` on the options object. You can either pass a JSON object of key value pairs like:
Expand Down Expand Up @@ -578,4 +591,4 @@ const config = await Parse.Config.get({useMasterKey: true});
const privateParam = config.get("privateParam");
```

By default, Parse Config parameters can be publicly read which may be undesired if the parameter contains sensitive information that should not be exposed to clients. A parameter can be made readable only with the master key by setting the `Requires master key?` property via the Parse Dashboard to `Yes`.
By default, Parse Config parameters can be publicly read which may be undesired if the parameter contains sensitive information that should not be exposed to clients. A parameter can be made readable only with the master key by setting the `Requires master key?` property via the Parse Dashboard to `Yes`.