모델 함수 내의 URL 또는 remoteMethod
으로 리디렉션하는 것과 관련된 설명서를 찾는 데 어려움을 겪고 있습니다. 여기 누가 이미 이것을 했습니까? 아래 코드를 찾으십시오. 모델 내부Loopback/Express : remoteMethod에서 URL로 리디렉션하는 방법은 무엇입니까?
기능 (를 노출/캐치 엔드 포인트)
Form.catch = function (id, data, cb) {
Form.findById(id, function (err, form) {
if (form) {
form.formentries.create({"input": data},
function(err, result) {
/*
Below i want the callback to redirect to a url
*/
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'}
});
감사합니다! – Jornve