I'm struggling to find the right words to explain my situation.
Essentially, I need to create an empty object that I plan to fill with data. I already have a clear idea of what the final structure of this object should be:
interface BodyInterface {
name: string;
lastName: string;
}
The data will be coming from a form submission and looks like this:
// The form data resembles:
// name: "foo"
// lastName: "bar"
My goal is to incorporate this data into an object that I can utilize later on:
const body = {}; // <- How can I implement the BodyInterface for this 'body' object
someArray.forEach(({ name, value }) => {
body[name] = data.get(name).value as string;
});
Any suggestions on how I could achieve this?