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

Pass list of dates to cloud code functions #1826

Closed
ideastouch opened this issue May 18, 2016 · 0 comments
Closed

Pass list of dates to cloud code functions #1826

ideastouch opened this issue May 18, 2016 · 0 comments
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@ideastouch
Copy link

The issue here is similar to the issue reported in #655 and #1697 but in this case the param is a list of dates instead of an one object of type date.
In Parse.com server works perfectly and in Parse-server running locally it is not works.

Test
In order to test this issue I am calling a cloud function checkDateList from my app. and I send two kind of params, first a Object of type Date and second a list of objects each one of type Date. Regarding the first parameter everything goes ok thanks to fix Pass dates to cloud code functions but regarding the second parameter I think that we have a bug.

Software versions

  • Parse-iOS-1.12.0
  • parse server ver 2.2.10.

Function definition

Parse.Cloud.define("checkDateList", function(request, response) {
    //Test of one object of type Date
    console.log('request.params.date: ' + request.params.date)
    var date  = request.params.date
    console.log('date : ' + date)
    console.log('date.getTime(): ' + date.getTime())

    //Test list of object each one of type Date
    console.log('request.params.dateList: ' + request.params.dateList)
    console.log('request.params.dateList[0]: ' + request.params.dateList[0])
    var isoDate = request.params.dateList[0]
    console.log('isoDate : ' + isoDate)
    console.log('isoDate.getTime(): ' + isoDate.getTime)

    if (isoDate.__type == 'Date') {
        var date = new Date(isoDate.iso)
        console.log('date : ' + date)
        console.log('date.getTime(): ' + date.getTime())
     }

Parse Server verbose log

$ VERBOSE=1  npm start

> troupefithrk@3.0.0 start /Users/<my name>/CODE/iDT/TroupeFit/troupefit-server
> node index.js

parse-server-example running on port 1337.
verbose: POST /parse/functions/submitAvailability { host: 'localhost:1337',
  'x-parse-client-version': 'i1.12.0',
  accept: '*/*',
  'x-parse-session-token': 'r:<parse session token>',
  'x-parse-application-id': ':<parse application id>',
  'x-parse-client-key': '<parse client key>',
  'x-parse-installation-id': <'parse installation id>',
  'x-parse-os-version': '9.3 (15E65)',
  'accept-language': 'en-us',
  'accept-encoding': 'gzip, deflate',
  'content-type': 'application/json; charset=utf-8',
  'content-length': '141',
  'user-agent': '<App Product Name>/35 CFNetwork/758.3.15 Darwin/15.4.0',
  connection: 'keep-alive',
  'x-parse-app-build-version': '35',
  'x-parse-app-display-version': '3.1' } {
  "date": {
    "__type": "Date",
    "iso": "2016-05-22T09:00:00.000Z"
  },
  "dateList": [
    {
      "__type": "Date",
      "iso": "2016-05-22T09:00:00.000Z"
    }
  ],
  "trainerId": "WZp1UiepFh"
}
request.params.date: Sun May 22 2016 02:00:00 GMT-0700 (PDT)
date : Sun May 22 2016 02:00:00 GMT-0700 (PDT)
date.getTime(): 1463907600000
request.params.dateList: [object Object]
request.params.dateList[0]: [object Object]
isoDate : [object Object]
isoDate.getTime(): undefined
date : Sun May 22 2016 02:00:00 GMT-0700 (PDT)
date.getTime(): 1463907600000

Result explanation
The parameter request.params.dateList should be a list of Date but instead is a list of objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

2 participants