Can anyone provide any guidance on how to redirect to a URL within a model function or remoteMethod
? I've been struggling to find documentation on this. Here is the code snippet for reference:
Model Function (Exposes /catch endpoint)
Form.catch = function (id, data, cb) {
Form.findById(id, function (err, form) {
if (form) {
form.formentries.create({"input": data},
function(err, result) {
/*
Would like to redirect to a url here
*/
cb(null, "http://google.be");
});
} else {
/*
console.log(err);
*/
let error = new Error();
error.message = 'Form not found';
error.statusCode = 404;
cb(error);
}
});
};
Form.remoteMethod('catch', {
http: {path: '/catch/:id', verb: 'post'},
description: "Public endpoint to create form entries",
accepts: [
{arg: 'id', type: 'string', http: {source: 'path'}},
{arg: 'formData', type: 'object', http: {source: 'body'}},
],
returns: {arg: 'Result', type: 'object'}
});