From the course: Next.js 14 from Scratch: Build a Real-World Project Using Next.js 14 and MongoDB

Unlock this course with a free trial

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

Requests file

Requests file

So we have this FetchProperties in both the HomeProperties component and the Properties page. So I think we should put that somewhere else. So I'm going to grab this from HomeProperties, the FetchProperties function, and cut that. And then let's create in the root a folder called Utils. I mean, you could really put this anywhere, but I'm going to put it in Utils. And I'm going to call this file requests.js. Now, I'm not going to put every request that I make in this file. You could do that if you want. You could create some kind of API service. But for the most part, we're going to be just fetching from the components. But for the basic get all properties or get a single property, we'll put those in here because we're going to use those in multiple places around the project. All right. So let's paste that in here. And then let's export that at the bottom. So we're going to export, not as default, because we're going to put some other stuff in here as well. But let's export Fetch…

Contents