Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Support for JSON params #67

Open
ghost opened this issue Feb 15, 2015 · 2 comments
Open

Support for JSON params #67

ghost opened this issue Feb 15, 2015 · 2 comments

Comments

@ghost
Copy link

ghost commented Feb 15, 2015

I am using REST API provided by parse.com and I need to pass complex JSON structure as parameters, e.g:

      params='{
        "order": "{{conf.sort.selected}}",
        "where": {
          "location": {
            "$nearSphere": {
              "__type": "GeoPoint",
              "latitude": "{{conf.location.lat}}",
              "longitude": "{{conf.location.lng}}"
            },
            "$maxDistanceInMiles": "{{conf.range.selected}}"
          }
        }
      }'

However the query string is not generated properly: ?order=-rating&where=%5Bobject%20Object%5D.

This is a common case, so would be nice to have this implemented!

@ghost
Copy link
Author

ghost commented Feb 16, 2015

See https://parse.com/docs/rest#geo-query for API reference.

@ghost
Copy link
Author

ghost commented Feb 16, 2015

I've found a workaround.

Params looks like this:

      params="{{ {order: conf.sort.selected, where: conf.whereCond} }}"

And there is an observer that updates whereCond:

  updateWhereCond: function() {
    this.conf.whereCond = JSON.stringify({
      location: {
        "$nearSphere": {
          "__type": "GeoPoint",
          "latitude": this.conf.location.lat,
          "longitude": this.conf.location.lng
        },
        "$maxDistanceInMiles": parseFloat(this.conf.range.selected)
      }
    });
  },

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants