Home > Blockchain >  Angular service syntax
Angular service syntax

Time:04-05

I'm trying to post certain data to the backend of my application (node.js and mysql) to send an email with this data.

I want to include two objects (account and labSwap) in this post method, what is the correct syntax/way to do this?

Thank you.

account.service.ts:

    notifyLecturer(account: Account, labSwap: LabSwap) {
        return this.http.post(`${baseUrl}/notifyLecturer`, account) , this.http.post(`${baseUrl}/notifyLecturer`, labSwap);
        // or &&?
    }

CodePudding user response:

is this what you are after??

notifyLecturer(account: Account, labSwap: LabSwap) {
    return this.http.post(`${baseUrl}/notifyLecturer`,  {account,labSwap})
}

payload will be like

{
  account:{accountJsonContent}, labSwap:{labswapJsonContent}
}
  • Related