From the course: The Freelance Stack: Real Project with Next.js and Strapi

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Event data processing

Event data processing

So, looking at the data, what we want to do is we want to make it a little bit easier to process, a little bit easier to work with now when we pass it into our sign-up form. In order for us to do that, we're going to do something very similar to what we've done already before with the info blocks or the block articles, and we're going to write a function that processes this kind of data. Now in here, if you look at it, we have to hook into event.data.data to get to this element right here. But that's the one we want. So we're going to treat it as if we're going to be handed exactly this JSON here. And what do we want to return for that? Well, we want to have all of the attributes as a new object and we want to have the id attached to this element as well. So I'm going to write a new function here that I'm just going to call processEventData like that. And it's going to take an event as an input and what it will return is a new object with exactly the event attributes spread in, and on…

Contents