2014-12-02 3 views
0

통합 구문 분석의 sendEmail 기능과 같이 설정 : 나는 컬 기능을 실행하고 콘솔을 시도 할 때마다나는 현재 튜토리얼 모듈에서 <a href="https://parse.com/tutorials/integrating-with-third-party-services" rel="nofollow">https://parse.com/tutorials/integrating-with-third-party-services</a></p> <p>다음있어 타사 서비스

sendEmail: function(params, options) { 
    return Parse.Cloud.httpRequest({ 
    method: "POST", 
    url: "https://api:" + key + "@" + url + "/" + domain + "/messages", 
    body: params, 
    }).then(function(httpResponse) { 
    if (options && options.success) { 
     options.success(httpResponse); 
    } 
    }, function(httpResponse) { 
    if (options && options.error) { 
     options.error(httpResponse); 
    } 
    }); 
} 

.log 옵션 해시, 옵션 해시는 항상 정의되지 않습니다.

결과는 내가

Parse.Cloud.define("sendEmailToUser", function(request, response) { 
    client.sendEmail({ 
    to: "[email protected]", 
    from: "[email protected]", 
    subject: "Hello from Parse!", 
    text: "Using Parse and My Mail Module is great!" 
    }).then(function(httpResponse) { 
    response.success("Email sent!"); 
    }, function(httpResponse) { 
    console.error(httpResponse); 
    response.error("Uh oh, something went wrong"); 
    }); 
}); 

가 어떻게 위의 콜백에 대한 HttpResponse 개체를 얻을 수있는 콜백에 대한 HttpResponse 개체를 얻을 수 있다는 것입니다?

답변

0

당신은 당신이 얻을 결과를 반환해야, 그것은/오류 처리기 다음 성공을 통과 했을까

sendEmail: function(params, options) { 
    return Parse.Cloud.httpRequest({ 
    ... 
    }).then(function(httpResponse) { 
    if (options && options.success) { 
     options.success(httpResponse); 
    } 
    return httpResponse 
    }, function(httpResponse) { 
    if (options && options.error) { 
     options.error(httpResponse); 
    } 
    return httpResponse 
    }); 
}