Mirroring the Server Part 3: SMTP.ts
The final worker, the one for the SMTP operation of sending a message, is, of course,
found in the SMTP.ts file. In this file, there are no interfaces to deal with, and just a single
method, so the entire file is this:
import axios from "axios";
import { config } from "./config";
export class Worker {
public async sendMessage(
inTo: string, inFrom: string, inSubject: string,
inMessage: string
): Promise {
await axios.post(`${config.serverAddress}/messages`, {
to : inTo, from : inFrom, subject : inSubject,
text : inMessage
});
}
}
I’m going to go out on a limb here and say you probably don’t even need this
explained at this point! So, with that assumption, let’s now move on to the true React
code that makes use of the Workers we just looked at.
Do'stlaringiz bilan baham: |