-1

The current situation:
The community I'm coding for has several sub communities with their own subdomains. Usually you could configure your webserver to allow requests between these subdomains. The community provider seems unable to provide this.

The current solution
To avoid CORS errors, we now using YQL for GET requests. This is approved by the community provider who have to review every script submitted by coders like me. This works already fine.

The current problem
I only figured out how to do GET requests using YQL. But is it possible to also POST data to another subdomain using YQL? And if it is, how do I do that?

shaedrich
  • 5,457
  • 3
  • 26
  • 42

1 Answers1

0

check out the documentation on how to make a POST-request:

var content = { "employee": { "name": "John", "id": 21 }};
var ret = request.contentType('application/json').post(content).response;

Source: https://developer.yahoo.com/yql/guide/yql_execute.html#post-method

  • Thanks for this! I read the example but I can't see where `y` is initialized. Does that only work with an yahoo account? – shaedrich Jun 12 '18 at 00:42
  • @shaedrich the `y` object is already initialized when your code runs, you don't need to do anything. Also, you don't need an Yahoo account to use YQL. – Vidar Flesjø Jun 12 '18 at 07:58
  • The question might be stupid but where is it initialized. Do I have to load a yql library? Before I just used the API directly. – shaedrich Jun 13 '18 at 01:10
  • Again, please read the documentation: https://developer.yahoo.com/yql/guide/yql_execute.html#yglobal `The y global object contains methods that provide basic YQL functionality within JavaScript. It also allows you to include YQL Open Data Tables and JavaScript from remote sources.` – Vidar Flesjø Jun 13 '18 at 18:07
  • That is not an answer. I know _what it is_, but not what I have to do that it is injected in `window` scope. – shaedrich Jun 13 '18 at 23:34
  • Oh, my assumption was that you were using custom table definitions, not javascript in browser. You will probably need to create a custom table xml with some javascript in it (that has the y-object). Hope this helps: https://developer.yahoo.com/yql/guide/dev-external_tables.html – Vidar Flesjø Jun 14 '18 at 06:09