Backbone model.save() sending request to root url - backbone.js

So when I call save on a new backbone model, save is sending a request to the base url defined in the model.
what I want is for save to issue a request to url/create.
the model isNew() returns true and all.

Related

How to include guests and notifications creating a new event in Google Calendar via URL

How to include guests and notifications as "GET" parameters when creating a new event in Google Calendar via URL (i.g. https://www.google.com/calendar/render?action=TEMPLATE&text=test&details=this+is+a+test&location=Italy&dates=20210119T165500Z%2F20210120T165500Z )?
Thanks
When creating a new event you want to use the method Events.insert which should be requested via POST request to:
POST https://www.googleapis.com/calendar/v3/calendars/calendarId/events
It takes several query parameters, but the Event resource (where the attendees are sent) should be passed as the body of the request. Not in the URL.

All of my Wordpress AJAX requests returns html page for subscribers. Why?

I have my ajax post calls from to create post by users under a custom post. I have used the action hook in all works fine for admins. But when a subscriber uses the same, it returns a html but not the response.
But the server-side is working fine on the ajax call. Meaning, the post has been created successfully and the mail also has been sent as expected (as per the code).
I have defined the ajax action hook for both prev and nonprev users.
add_action('wp_ajax_register_participant', 'register_participant_callback');
add_action('wp_ajax_nopriv_register_participant', 'register_participant_callback');
I have also defined the capability type and map_meta_cap while registering the custom post type and set the permission to edit, update and delete the 'registration' post type.
'capability_type'=> 'registration',
'map_meta_cap' => true,
It was actually working fine but suddenly stopped working on all my ajax calls.
Any suggestions to debug?

Calling update method on custom model

I have created a custom model which I plan to use to change a custom field attached to the Contacts record. I have created the SuiteScript file, JavaScript file and Service Controller.
I am not too sure how SCA communicates with the server but I assume that you call the frontend model from the View, which then calls the Service Controller which in turn calls the backend model.
I am able to call the frontend model so I think it is set up correctly, the problem I am having is calling the update function on the backend.
The code below is the part of the frontend model that is called.
updateEmbroidery: function updateEmbroidery(newValue, contactId) {
this.set('id', '56');
this.set('value', newValue);
}
The new values show when the model is logged. Trying this.sync also throws an error.
there is a frontend model and a backend model. the frontend model merely says, "here is the URL of the backend model", which, as you noted, has an intermediary, which is the service controller.
The service controller just says, "call x function for put, get, post", etc, and you have to define "x" in the backend model.
the backend model should contain all the standard SuiteScript 1.0 code needed for your CRUD matrix.

AngularJS/Router minimize API calls

Would it be possible to make all the API calls once when the user lands on the page from the url and store all the data as cache and then use the cache to render the state changes from Angular router?
I can see it being implemented by a service that populates the rootscope but would this method be recommended instead of calling the API multiple times?
You can use use $http and set cache to true.
Should be enough for your needs.
From documentation:
The default cache value can be set by updating the $http.defaults.cache property or the $httpProvider.defaults.cache
property.
When caching is enabled, $http stores the response from the server
using the relevant cache object. The next time the same request is
made, the response is returned from the cache without sending a
request to the server.
Take note that:
Only GET and JSONP requests are cached. The cache key is the request
URL including search parameters; headers are not considered. Cached
responses are returned asynchronously, in the same way as responses
from the server. If multiple identical requests are made using the
same cache, which is not yet populated, one request will be made to
the server and remaining requests will return the same response. A
cache-control header on the response does not affect if or how
responses are cached.

Accessing Session values in Angular.js

I am unable to access the session values which is set by node.js in Angular.js controller. I am using the Express framework. How to resolve it? Here is my code.
app.use(express.cookieParser());
app.use(express.session({
secret: '1234567890QWERTY',
cookie: { httpOnly: false }
}));
//setting the values
cookies.set('username',username);
req.session.username=username;
Presumably you want to do something like show the username in your angular app. As I mentioned in this answer, the hard part to Angular is not thinking about what data the server has, but thinking about data the server should provide to the browser via API.
My general model is to have the angular page start up without any data and have a low-level controller invoke a service (say AuthenticationService or IdentityService) that requests relevant data from the server, e.g. HTTP GET /api/identity. That will return a block of JSON that the page can then store in that low-level controller. Any deeper controller can then access the identity (or whatever) data loaded in that first request.

Resources