I am a developer with hyperledger composer. I have one question about JavaScript file of hyperledger composer "What is a JavaScript file of hyperledger composer can use XMLHttpRequest?", because I want to use REST API from server in the JS file of hyperledger composer.Or I can use something else to achieve this.
Following script is doing Same Domain Ajax request in the HyperLedger.
You can use almost all the javascript standard code inside the Script file.
see the function sendrequest is sending two additional data to the demo_get2 end point
The Ajax is executed the moment i submit a transaction (Because i am calling sendrequest inside the transaction processor function .
Related
Hello I want to make a request to a xml file for a value I want on Code by Zapier, but I get the error XMLHttpRequest is not defined. I also tried var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; but it says Error: Cannot find module 'xmlhttprequest'.
While the XMLHttpRequest is available in most browsers, it is not distributed in Node, which is what the Code action is using. Specifically, the Javascript code action is running a Node v10.x.x environment. You can see all of the commands and methods supported by that environment here:
https://node.green/
The JS environment does support the Fetch library for making requests. Perhaps you can look into making this work?
https://github.com/node-fetch/node-fetch
In the StackExchange.Redis docs for scripting, it says a LoadedLuaScript can be used to avoid retransmitting the Lua script to redis each time it is evaluated. It then gives an example where the script is loaded into the server. I assume this shouldn't be done everytime you call the script, so where should the scripts be loaded?
Scripts are not persitent if redis server is restarted, so how should this be handled? Should they be loaded in ConnectionRestored event of the ConnectionMultiplexer? Presumably you would need to store them in a ConcurrentDictionary?
StackExchange.Redis handles Lua script caching internally. Normally you don't have to care about loading Lua scripts manually to redis.
StackExchange.Redis automatically transmits the Lua script to redis on the first call to 'ScriptEvaluate'. For further calls of the same script only the hash is used:
var prepared = LuaScript.Prepare(script);
prepared.Evaluate(someDb); // loads the script to redis and calls it
var prepared2 = LuaScript.Prepare(script);
prepared2.Evaluate(someDb); // calls the script by it's hash
LoadedLuaScript might be useful for edge cases like loading without executing.
I also clarified the official doku.
Background information
The library tries to call the script by it's hash and if the script is missing it gets a NOSCRIPT error and then transmits the script.
See ScriptEvalMessage:GetMessages in https://github.com/StackExchange/StackExchange.Redis/blob/main/src/StackExchange.Redis/RedisDatabase.cs
The behavior is also discussed and explained in the official StackExchange.Redis github repo:
https://github.com/StackExchange/StackExchange.Redis/issues/1246
https://github.com/StackExchange/StackExchange.Redis/issues/1371
I'd like to execute a shell script form my Rails app on the client.
In my case, I want to open a .odt file on the Client PC when he clicks on a link.
As for now, all I can do is run shell script on my server using e.g.
`libreoffice path_to_my_odt_file`.
In this case, I'm opening my file using LivreOffice on the Server.
Is there a way to execute this code on my Client from Rails?
If I try to run my app as it is, when I call the action that calls my script, the file is opened on my Server.
Thank you in advance.
As mentionned in the comments, running arbitrary shell scripts on the client from the http server would be a huge security flaw.
As long as your Rails server provides a download link with send_data (e.g. dynamically_generated_odt_file), the browser will ask if it should download the file or open it. If the user wants to avoid any extra interaction, there's the possibility to tick :
"Do this automatically for files like this from now on"
You might have to specify the MIME type, by adding
Mime::Type.register "application/vnd.oasis.opendocument.text", :odt
to config/initializers/mime_types.rb.
I am trying to understand the new Parse Server and have deployed on Heroku. This went smoothly but what I am struggling with is figuring out how to write server side code (Cloud Code). I've read over the parse server example many times so I must be missing something but I'm very unclear if I should be using Express for something, or how I even begin to include my Cloud Code files. Any help is very much appreciated.
UPDATE:
I found the cloud folder I was just looking in the wrong place. I moved it and index.js to my apps folder on the desktop. I have changed the default code in main.js to my custom code. I have set up index.js with my apps information. The problem now is when I run the app and try to call the cloud code functions I get error invalid function.
If you have the parse server example running on heroku you are 90 percent there. Just open the cloud/main.js file and start adding your cloud code. There should be a hello cloud function there as an example.
To use your already created cloud code modules/files you can require them as you have done before on parse.com. The only difference is that the path should now be relative instead of absolute. For example require('cloud/cloudFunctions'); should be require('./cloudFunctions'); if you had a module called cloudFunctions.js in the cloud directory.
Cloud Code works similar to how it did on parse.com and you shouldn't have to think too much about expressjs for simple applications. That said, parse server is using expressjs so yes you are using it.
Parse server is simply a another node module similar to the other thousands available. If you do not have previous experience with nodejs, running parse server can seem complicated. Therefore I would recommend reading about the basics of nodejs before a full migration.
I'm using the Bitnami stack on a Google Compute Engine instance and I had a similar problem to yours. To solve it, just navigate to the folder where your server.js file is and create a folder called "cloud". Then create the main.js file inside the cloud folder with the following content:
Parse.Cloud.define('hello', function(req, res) {
res.success('Hi');
});
Now open the server.js file and find the line containing the path to the cloud code file. Change it to point to you main.js file like this:
This could be any arbitrary folder of your choosing.
Now just restart your parse server and call the cloud function:
String result = ParseCloud.callFunction("hello", new HashMap<>());
This is with the Java SDK but should not be much different. The variable result will equal "Hi" if you've used the function from above.
https://github.com/devbridge/jQuery-Autocomplete
found this tutorial and was able to run it implement it on my app.my problem is, it wont run on local computer/app i think the problem is with mockjax is there way to make this tutorial run locally?or is there other way to make an autocomplete locally?this example is about autocomplete.
In the config lookup is for local data that doesn't rely on external requests. This would rely on loading in the data through JS on the client.
If you want to run it locally why not boot up a simple http server with python and make a get request to a local file?
See here line 133: https://github.com/michaelBenin/Airport-Distance-Calculator/blob/master/script.js