209 похожих чатов

RegisterPayment(Customer: string, sessionId: string, amount: number) { this.counterModel.findOneAndUpdate(

{},
{$inc: { seqNo: 1 } },
{new: true, upsert: true},
(err, doc) => {
if (err) {
console.log("err => " + err);
}
if (doc) {
console.log('doc seqNo => ' + doc.seqNo);
this.httpService.post("https://xxxxxxx.ru/payment/rest/registerPayment",
{},
{
headers: { "Content-Type": "application/x-www-form-urlencoded" },
params: {
orderNumber: doc.seqNo,
amount: amount,
returnUrl: "http://localhost:4200/" + customer + "/payment/registerpayment",
userName: "xxx",
password: "xxx"
}
})
.pipe(
// tap(console.log),
map(res => res.data),
tap(res => {
console.log("response => ", res);
console.log("sessionId => ", sessionId);
console.log("doc.seqNo => " + doc.seqNo);
this.paymentModel.findOneAndUpdate(
{ "sessionId": sessionId },
{
"orderId": res.orderId ? res.orderId : res.errorMessage,
"seqNo": doc.seqNo
}
).exec()
})
).subscribe(r => {console.log('in subscribe ',r)});
}
}
)

return ??????
}

3 ответов

13 просмотров
Evgeny-Kiryanov Автор вопроса

Как сделать, чтобы объект из subscribe попал в return?

Evgeny Kiryanov
Как сделать, чтобы объект из subscribe попал в ret...

возвращай промис с функции и делай ресолв в subscribe

Из observable не вернешь, но можешь вернуть сам observable, т.е. сложить все это в переменную, затем const data = await firstValueFrom(observable$)

Похожие вопросы

Обсуждают сегодня

Карта сайта