javascript - Meteor HTTP request structuring -


i playing around api in meteor , trying use http package access it. example give formats request curl command :

curl -x post https://api.locu.com/v2/venue/search/ -d '{"fields":["name","menu_items","location","categories","description"],"menu_item_queries":[{"price":{"$ge":15},"name":"steak"}],"venue_queries":[{"location":{"locality":"san francisco"}}],"api_key":"your_api_key"}' 

how convert http.call()? use data argument see listed in docs? params? content? variations have tried far haven't worked.

this equivalent. it's bit prettier in javascript.

server side code:

var result = http.post("https://api.locu.com/v2/venue/search", {     data: {         "fields": ["name", "menu_items", "location", "categories", "description"],         "menu_item_queries": [{             "price": {                 "$ge": 15             },             "name": "steak"         }],         "venue_queries": [{             "location": {                 "locality": "san francisco"             }         }],         "api_key": "your_api_key"     } });  console.log(result.data); // console.log(result.content); //.data better if output in json 

if use client-side code, not advised due api key, have use callback instead.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -