How can I call a custom endpoint from within a custom endpoint? I know that the HTML5 SDK has this method: Kinvey.CustomEndpoint.execute(). Do I have to use the REST API? Example: modules.request.request(opts, function (error, resp, body) { });
Thank you.
Best Answer
P
Pranav J
said
about 2 years ago
Hello John,
Yes. You will have to use modules.request.request(). Check the following code for a better understanding:
var req = modules.request;
var endpointName = 'secondEndpoint';
var uriString = 'https://baas.kinvey.com/rpc/' + modules.backendContext.getAppKey() + '/custom/' + endpointName;
var opts = {
uri: uriString,
method: 'post',
headers: {'Authorization': request.headers.authorization},
json: true
};
req.request(opts, function (err, resp, body) {
if (err) {
} else {
}
});
Thanks,
Pranav
1 Comment
P
Pranav J
said
about 2 years ago
Answer
Hello John,
Yes. You will have to use modules.request.request(). Check the following code for a better understanding:
var req = modules.request;
var endpointName = 'secondEndpoint';
var uriString = 'https://baas.kinvey.com/rpc/' + modules.backendContext.getAppKey() + '/custom/' + endpointName;
var opts = {
uri: uriString,
method: 'post',
headers: {'Authorization': request.headers.authorization},
json: true
};
req.request(opts, function (err, resp, body) {
if (err) {
} else {
}
});
John Smith
Hello.
How can I call a custom endpoint from within a custom endpoint? I know that the HTML5 SDK has this method: Kinvey.CustomEndpoint.execute(). Do I have to use the REST API? Example: modules.request.request(opts, function (error, resp, body) { });
Thank you.
Hello John,
Yes. You will have to use modules.request.request(). Check the following code for a better understanding:
Thanks,
Pranav
Pranav J
Hello John,
Yes. You will have to use modules.request.request(). Check the following code for a better understanding:
Thanks,
Pranav
1 person likes this
-
How do I access query string values for GET and DELETE requests?
-
Basic Authentication in Business Logic
-
How do I cascade delete entities from related collections?
-
All BL failing with Violation Error
-
How do I send push notifications?
-
Whenever I try to query by _id, I get zero results
-
receiving SOCKETTIMEDOUT when requesting external http response
-
Unique Constraints on a collection column?
-
Need some help with grouping
-
Accessing Endpoint from Collection Hook
See all 342 topics