I am new to restangular and angular
we have a function that looks like
function (service_url, method){
$http({
url: service_url,
method: method,
data: {
},
headers: {
}
})
}
as you can see the method is being passed by the caller of this function I need the same functionality in restangular any help will be appreciated kindly excuse my lack of knowledge
Related
I am trying to use vuex's store to make some API calls but after installing vuex, importing store to my files and following other stack overflow answers, like making sure vuex is installed, if i am exporting my store file with " Vuex.Store" and etc but my loadCalls function is still not working.
This is the error i get:
this.$store.loadCalls is not a function
Here is my function and how i am trying to call it, it is declared in my ACTIONS section of my store.js file.
loadCalls() {
axios
.get("/some/calls")
.then(res => {
console.log(res)
});
},
I try using it in my beforeMount() when my component loads:
beforeMount(){
this.$store.loadCalls();
}
What am i doing wrong here?
If you defined an action like this:
actions: {
loadCalls() {
// ...
}
}
Then you would call it like this:
this.$store.dispatch('loadCalls');
Actions aren't exposed directly, you call them using dispatch.
https://vuex.vuejs.org/guide/actions.html#dispatching-actions
Im using Hapi 12.1.
Trying to figure out how to call certain extension points only on certain routes.
For example for :
'/hello'
I want to call three different extension points that work on the 'onRequest' step.
For:
'/goodbye'
I want to call a different extension point that works also on the 'onRequest' but is a different operation and a 'onPreAuth' step.
For:
'/health'
Dont call any extension points, and just drop into the handler straight away..
I have tried various ways to create a plugin, define the routes, and extension points. But it seems the the extension points are global, and dont only operation on the plugin's scoped routes.
What am I missing?
You have access to the path on your extension points, using request.route.path. With that, you can define what you want to run, depending on the path. Example:
server.ext('onPreAuth', function (request, reply) {
switch(request.route.path) {
case '/test1':
case '/test2':
// Do something
break;
case '/test3':
// Do something else
break;
}
reply.continue();
});
Alternatively, you can also make it dependent on the route configuration:
server.ext('onPreAuth', function (request, reply) {
if(request.route.settings.plugins.runPreAuth) {
// Do something
}
reply.continue();
});
Then, you just define in your route the configurations:
server.route({
method: 'get',
path: '/test1',
handler: function(request, reply) {
reply({result: 'ok'});
},
config: {
plugins: {
runPreAuth: true
}
}
});
According to the release doc, Regula 1.3.0 should support async validation. It seems that compound constraints are able to take an option of async in some way. Does this hold true for custom validations as well? What would be the syntax for this?
I'm still working on finishing the documentation for 1.3 (what I have so far is available here).
Asynchronous support is available for both custom constraints and compound constraints (that contain at least one asynchronous constraint).
The syntax to define an asynchronous constraint is pretty simple:
regula.custom({
name: "MyAsyncContraint",
async: true,
defaultMessage: "The asynchronous constraint failed.",
validator: function(params, validator, callback) {
//Using jQuery as an example
jQuery.ajax({
url: myUrl,
dataType: "jsonp",
success: function(data) {
//Use the callback to pass the result of validation back to
//regula.
callback(data.pass)
}
});
}
});
There is no explicit syntax or call to make a compound constraint asynchronous. Any compound constraint that contains one or more asynchronous is implicitly asynchronous. To validate asynchronous constraints (or even a mix of synchronous and asynchronous constraints), you just pass a callback to .validate:
regula.validate(function(constraintViolations) {
...
});
You can use .validate with options and a callback as well:
regula.validate(options, function(constraintViolations) {
...
});
First of all i am using play framework with scala,
What i have to do is , using the data which i am getting with that function;
onClick: function(node) {
if(!node) return;
alert(node.id);
var id = node.id;
}
So what the question is how i can call the methods from controller with this id ? Since js is client-side but scala works with server-side , i need something creative.
This is the function i need to call from my controller.
def supertrack(id:Long) = Action {
}
I have just found out that i need use ScalaJavaScriptRouting in order to send a ajax request to the server.
For the documentation
http://www.playframework.com/documentation/2.1.1/ScalaJavascriptRouting
I'm using Apache Wink for implementing REST Services and I can't seem to receive parameters of type array or List. The call is being made from ajax $.post:
$.post(url,
{ param: ['string1', 'param2', 'x', 'etc...etc....etc'],
str2: "str2"},
function(data) {// do something
});
On the server side, Strings and ints are correctly received, but the 'param' parameter is always received empty (not null, but with zero elements), whether the variable is defined as String[], List, Set, ... . The receiving function is defined as:
#POST #Produces("application/json") #Path("eee")
public Response eee(#FormParam("str1") String str1, #FormParam("param") String[] param, #FormParam("str2") String str2)
While debugging, I can see a context variable with a table entry like:
wink.formParameters=[param%5B%5D=string1,param%5B%5D=param2,param%5B%5D=x,param%5B%5D=etc...etc....etc,str2=str2]
That translates to 'param[]=string1, param[]=param2, ..', no indexation. Don't know if that's correct.
Any ideas ?
I realize this is an old question, but I had a similar problem, and I ended up fixing it by adding [] to the end of the FormParam name.
So instead of having #FormParam("param"), you would have #FormParam("param[]")
Note that I am also using jQuery's $.params method to serialize my data, but I it looks like your debugging revealed a properly-encoded form string, so I'm suspecting it's just the [] that are missing.
This works for me when I define the accepting variable as :
#FormParam("paramName") List<String> paramList;
You might also need to tweak the client call like:
$.post(url,
{ paramName: "string1",
{ paramName: "string2",
{ paramName: "string3",
str2: "str2"},
function(data) {// do something
});