3

How did I build 🏗️my first 🗄️API with MongoDB and Next.js?

 2 years ago
source link: https://dev.to/theabhayprajapati/how-did-i-build-my-first-api-with-mongodb-and-nextjs-4jij
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Cover image for How did I build 🏗️my first 🗄️API with MongoDB and Next.js?

How did I build 🏗️my first 🗄️API with MongoDB and Next.js?

By the way, I am a frontend developer🧑🏿‍💻, I always love to use APIs and work with them.
but the project that I was wanted to build API is like Apple's 🍎 Store,
and this gave me the will to build an API and release it,
A few weeks ago I completed working with my Clone Of Twitter Project, where I had used **Firebase **as a database,
but now I wanted to push myself and use **MongoDB **as a database.

After thinking a while I start with the project's building

Open source Apple Store API.

using Next.js API Routes it has become very easy to manage the backend.
I make simple routing and pages so if the comes to this page will be provided with other these data.

BaseUrl : https://oas.vercel.app/api

baseUrl /all
ThanosInfinityWarGIF.gif

it provides all the data from the database, from all the categories without filteration. 😊

/category/:category

baseurl /category/iphone

PhirHeraPheriBCategoryKeCClassLogGIF.gif

here you can add category for your output. and result will be from that category only.
example: + /category/watch
+ /category/iphone
+ /category/macbook
+ /category/airpods
+ /category/ipad

/series/:series

baseurl /series/MacBook Air
🧑‍💻every product has series name such as iPhone 13 has series name such as iPhone 13, under iPhone 13 two products come iPhone 13 & iPhone 13 mini.

They are case sentitive 😓 so iphone_13, iPhone_13 won't work ❌,
correct way /series/iPhone 13 ✅
without %20

/:_Id

baseurl /6228d7ac2e00fb1164b2df27

DoYouHaveIdWhoAreYouGIF.gif

for getting results realted to single product the /:_Id is used.
example: /6228d7ac2e00fb1164b2df27,
these are id sentitive fetch with their respective id's.😅

{
    "data": {
        "_id": "6228d7ac2e00fb1164b2df27",
        "product_name": "MacBook Pro",
        "product_price": {
            "IN": 109000,
            "US": 999,
            "GBP": 899
    },
    "product_description": "Id culpa aliquip ipsum excepteur sunt incididunt laboris magna incididunt nostrud.",
}
}

Enter fullscreen mode

Exit fullscreen mode

CatDrivingGIF.gif

This is how I worked 💪🏾on routing/ and requests.

use this project and let me how was it, I'll your projects' in the featured section.

Share 🤝🏾 you ideas thought's regarding this I try to implement that.

BusinessmenHandshakeGIF.gif

Connect with on
Twitter : @AbhayPrajapati_
Github : @theabhayprajapati
👋🏾


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK