{"id":167,"date":"2024-08-05T10:24:02","date_gmt":"2024-08-05T10:24:02","guid":{"rendered":"http:\/\/217.217.250.244\/blogs\/?p=167"},"modified":"2026-03-29T06:41:23","modified_gmt":"2026-03-29T06:41:23","slug":"whats-the-best-way-to-mock-an-api-using-app-router","status":"publish","type":"post","link":"https:\/\/faux-api.com\/blogs\/whats-the-best-way-to-mock-an-api-using-app-router\/","title":{"rendered":"What&#8217;s the best way to mock an API using app router?"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/faux-api.com\/blogs\/wp-content\/uploads\/2024\/08\/whats-the-best-way-to-mock-an-api-using-app-router-1024x683.webp\" alt=\"whats-the-best-way-to-mock-an-api-using-app-router\" width=\"1024\" height=\"683\" class=\"alignnone size-large wp-image-186\" srcset=\"https:\/\/faux-api.com\/blogs\/wp-content\/uploads\/2024\/08\/whats-the-best-way-to-mock-an-api-using-app-router-1024x683.webp 1024w, https:\/\/faux-api.com\/blogs\/wp-content\/uploads\/2024\/08\/whats-the-best-way-to-mock-an-api-using-app-router-300x200.webp 300w, https:\/\/faux-api.com\/blogs\/wp-content\/uploads\/2024\/08\/whats-the-best-way-to-mock-an-api-using-app-router.webp 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p>Effective testing ensures you have developed an application that runs smoothly and meets your users&#8217; expectations. There are many methods you can use in order to test your app. However, mocking API stands out as the perfect method to test an application because it allows you to test your app without relying on live data.<\/p>\n<p>You can mock an API through various paths. However, you should mock an API using app router because it is among the reliable ways to mock APIs. Still, many people struggle to do so because they don\u2019t know the right way. Today, we are going to provide you with the best way to mock your API using an app router. <\/p>\n<h2>Why should you consider mocking an API using an app router?<\/h2>\n<p>If you are a developer, you might be aware of the fact that mocking API can help you to work more efficiently in a controlled zone with isolated components in order to get better testing results. You can improve these benefits by mocking an API using app router. <\/p>\n<p>App routers can be excellent for you if you are mocking an API because they will help you to decrease delays by letting progress without the actual API. It helps your team to work on different components of an application simultaneously, leading to a faster development process. <\/p>\n<h2>Best way to mock an API using app router<\/h2>\n<p>When mocking an API through an app router, you must follow a few simple steps. However, you also need to do some basic coding. The best way you should follow to mock an API is mentioned below:<\/p>\n<h3>1. Initialize the project and install dependencies<\/h3>\n<p>To start the project and install dependencies, you have to go to your project directory. We have mentioned the steps you required to go to your directory:<\/p>\n<ul class=\"padding-h3\">\n<li>\n<p>Open your terminal or prompt a command<\/p>\n<\/li>\n<li>\n<p>Once opening your terminal or prompting, you should navigate to the directory where you wish to develop your project.\n<\/p>\n<\/li>\n<\/ul>\n<p class=\"padding-h3\">After navigating the directory, you should develop a package.json by running the command <\/p>\n<p><code class=\"padding-h3 mb-1\"><\/p>\n<pre>npm init -y<\/pre>\n<p><\/code><\/p>\n<p class=\"padding-h3\">in order to activate the new Node.js project. It will develop a basic package.json file within the default setting.<\/p>\n<p class=\"padding-h3\">To proceed, execute the command:<\/p>\n<p><code class=\"padding-h3 mb-1\"><\/p>\n<pre>npm install express<\/pre>\n<p><\/code><\/p>\n<p class=\"padding-h3\">It will install the <a href=\"https:\/\/www.npmjs.com\/package\/express\" rel=\"noopener nofollow\" target=\"_blank\">Express npm package<\/a>. However, you need to include this framework in your package.json as a dependency. <\/p>\n<p class=\"padding-h3\">Lastly, you should develop a new file for your main server code and create another file named Mockdata.js for the mockdata you want to use.   <\/p>\n<h3>2. Set up a mock data <\/h3>\n<p class=\"padding-h3\">Next, you must set up mock data by adding the following code in mockdata.js: <\/p>\n<p><code class=\"padding-h3\"><\/p>\n<pre>let products = [\r\n  { id: 1, name: 'Product A', description: 'Description of Product A', ratings: '5', brand: 'Google' },\r\n  { id: 2, name: 'Product B', description: 'Description of Product B', ratings: '4', brand: 'Apple' },\r\n  { id: 3, name: 'Product C', description: 'Description of Product C', ratings: '2', brand: 'Microsoft' }\r\n];\r\n\r\nmodule.exports = {\r\n  products\r\n};\r\n<\/pre>\n<p><\/code><\/p>\n<h3>3. Set up express server<\/h3>\n<p class=\"padding-h3\">Once setting up a mock data, you should set up an express server by adding the following code:<\/p>\n<p><code class=\"padding-h3 mb-1\"><\/p>\n<pre>const express = require('express');\r\nconst { products } = require('.\/mockData'); \/\/ Import the products array\r\nconst app = express();\r\nconst port = 3000;\r\n\r\napp.use(express.json());\r\n<\/pre>\n<p><\/code><\/p>\n<p class=\"padding-h3\"><strong>Explanation<\/strong><\/p>\n<ul class=\"padding-h3\">\n<li>\n<p>With this code, express is imported in order to create a web server.<\/p>\n<\/li>\n<li>\n<p>The mockData module also provides the import of the product array.<\/p>\n<\/li>\n<li>\n<p>An express application is developed and assigned to an app.<\/p>\n<\/li>\n<li>\n<p>The server is ready to listen on port 300.<\/p>\n<\/li>\n<li>\n<p>express.json() middleware is used to parse incoming JSON requests.<\/p>\n<\/li>\n<\/ul>\n<h3>4. Define the route for CRUD operations<\/h3>\n<p class=\"padding-h3\">Once setting up your express servers, you should define the route for the CRUD operations. The following are the steps you need to follow to define these routes:<\/p>\n<p><code class=\"padding-h3 mb-1\"><\/p>\n<pre>\/\/ Get all products\r\napp.get('\/api\/products', (req, res) => {\r\n  res.json(products);\r\n});\r\n<\/pre>\n<p><\/code><\/p>\n<p class=\"padding-h3\"><strong>Explanation<\/strong> <\/p>\n<ul class=\"padding-h3\">\n<li>\n<p>It will respond with the complete list of products when a get request is made to \/api\/products.<\/p>\n<\/li>\n<\/ul>\n<p><code class=\"padding-h3 mb-1 mt-3\"><\/p>\n<pre>\/\/ Get a product by ID\r\n\r\napp.get('\/api\/products\/:productId', (req, res) => {\r\n  const productId = req.params.productId;\r\n  const productFilter = products.filter(product => product.id == productId);\r\n  res.json(productFilter);\r\n});\r\n<\/pre>\n<p><\/code><\/p>\n<p class=\"padding-h3\"><strong>Explanation <\/strong><\/p>\n<ul class=\"padding-h3\">\n<li>\n<p>It fetches the product by its ID from the URL (ProductID) and responds with a similar or the same product.<\/p>\n<\/li>\n<li>\n<p>It utilizes the .filter() method in order to locate the product with a matching ID.<\/p>\n<\/li>\n<\/ul>\n<p><code class=\"padding-h3 mb-1 mt-3\"><\/p>\n<pre>\/\/ Delete a product by ID\r\n\r\napp.delete('\/api\/products\/:productId', (req, res) => {\r\n  products.map((item, index) => {\r\n    if (item.id == req.params.productId) {\r\n      products.splice(index, 1);\r\n      res.send(products); \r\n    } else {\r\n      res.send('not found'); \r\n    }\r\n  });\r\n});\r\n<\/pre>\n<p><\/code><\/p>\n<p class=\"padding-h3\"><strong>Explanation <\/strong><\/p>\n<ul class=\"padding-h3\">\n<li>\n<p>This route will delete the product by its ID through a delete request.<\/p>\n<\/li>\n<li>\n<p>The map() function iterates or replicates over the products array and removes the product using .splice() if a match is found.<\/p>\n<\/li>\n<\/ul>\n<p><code class=\"padding-h3 mb-1 mt-3\"><\/p>\n<pre>\/\/ Update a product by ID\r\n\r\napp.put('\/api\/products\/:productId', (req, res) => {\r\n  let productFound = false;\r\n  products.map((item, index) => {\r\n    if (item.id == req.params.productId) {\r\n      productFound = true;\r\n      Object.keys(req.body).map((key) => {\r\n        item[key] = req.body[key];\r\n      });\r\n      res.send(products); \r\n    }\r\n  });\r\n  productFound ? res.send(products) : res.send('Not Found');\r\n});\r\n<\/pre>\n<p><\/code><\/p>\n<p class=\"padding-h3\"><strong>Explanation <\/strong><\/p>\n<ul class=\"padding-h3\">\n<li>\n<p>This route updates an existing product by its ID with the use of a PUT request.<\/p>\n<\/li>\n<li>\n<p>It also checks whether the product is available. If found, it updates the product property with the data provided in the request body.<\/p>\n<\/li>\n<\/ul>\n<h3>5. Start the server<\/h3>\n<p class=\"padding-h3\">Lastly, you should start the server with the help of the code mentioned below:<\/p>\n<p><code class=\"padding-h3 mb-1\"><\/p>\n<pre>app.listen(port, () =>{\r\n  console.log(`Server is running at http:\/\/localhost:${port}`);\r\n});\r\n<\/pre>\n<p><\/code><\/p>\n<p class=\"padding-h3\"><strong>Explanation<\/strong> <\/p>\n<ul class=\"padding-h3\">\n<li>\n<p>The server is started and listens to the incoming request on Port 3000.<\/p>\n<\/li>\n<li>\n<p>A message is delivered to the server that indicates the server is running.<\/p>\n<\/li>\n<\/ul>\n<h2>You should copy and paste the code mentioned below to complete\u00a0the\u00a0process:<\/h2>\n<p><code><\/p>\n<pre>const express = require('express');\r\nconst { products } = require('.\/mockData');\r\nconst app = express();\r\nconst port = 3000;\r\n\r\napp.use(express.json());\r\n\r\n\r\n\/\/ Get all value\r\napp.get('\/api\/products', (req, res) => {\r\n  res.json(products);\r\n});\r\n\r\n\/\/ Get the value by using ID\r\napp.get('\/api\/products\/:productId', (req, res) => {\r\n  const productId = req.params.productId;\r\n  const productFilter = products.filter(products => products.id == productId);\r\n  res.json(productFilter);\r\n});\r\n\r\n\/\/ Insert the value\r\napp.post('\/api\/products', (req, res) => {\r\n  products.push(req.body)\r\n  res.send(products); \r\n});\r\n\r\n\/\/ Delete the value by using ID\r\napp.delete('\/api\/products\/:productId', (req, res) => {\r\n  products.map((item, index)=>{\r\n    if(item.id == req.params.productId) {\r\n      products.splice(index, 1);\r\n      res.send(products); \r\n    } else {\r\n      res.send('not found'); \r\n    }\r\n  })\r\n});\r\n\r\n\/\/ Update the value by using ID and pass data in JSON format\r\napp.put('\/api\/products\/:productId', (req, res) => {\r\n  let productFound = false;\r\n  products.map((item, index)=>{\r\n    if(item.id == req.params.productId) {\r\n      productFound = true\r\n      Object.keys(req.body).map((key)=>{\r\n          item[key] = req.body[key]\r\n      })\r\n      res.send(products); \r\n    }\r\n  })\r\n  productFound ? res.send(products) : res.send('Not Found');\r\n});\r\n\r\n\r\n\r\n\/\/ Start the server\r\napp.listen(port, () => {\r\n  console.log(`Server is running at http:\/\/localhost:${port}`);\r\n});\r\n<\/pre>\n<p><\/code><\/p>\n<h2>Conclusion <\/h2>\n<p>\nTo test a product or application effectively, using a mock API with an app router is a practical approach. It allows you to simulate real API behavior and validate your application without relying on a live backend.\n<\/p>\n<p>\nIn this article, we have outlined simple and effective steps to help you create and use mock APIs with ease. By following this guide, you can improve testing, identify issues early, and streamline your development process.\n<\/p>\n<p>\nIf you prefer a faster solution, you can use the <a href=\"https:\/\/faux-api.com\/instantAPI\">Faux Instant API<\/a> to instantly create mock APIs without signup, or use Faux production API to set up APIs for your project with ease after <a href=\"https:\/\/dashboard.faux-api.com\/signup\">signingup<\/a>.\n<\/p>\n<h2>FAQ<\/h2>\n<h4>1. Can we create an API using node\/express?<\/h4>\n<p>Yes, you can use Node.js and Express.js to create an API. Express.js is among the famous frameworks to develop an API on top of Node.js.<\/p>\n<h4>2. Is express node good for creating a mock API?<\/h4>\n<p>Yes, express is a popular option for developing mock APIs because of its flexibility and ease of use. <\/p>\n<h4>3. Why should you use faux API instead of Node express to mock an API?<\/h4>\n<p>\nBuilding a mock API using Node or Express often involves multiple setup steps. Instead, you can use the<br \/>\n<a href=\"https:\/\/faux-api.com\/instantAPI\">Faux Instant API<\/a> to create mock APIs instantly without signup. It provides a simple and efficient way to generate APIs without complex configuration. You can get started quickly and focus on development without additional effort. <a href=\"https:\/\/faux-api.com\/instantAPI\/\" title=\"Start mocking your API today\">Start mocking your API today.<\/a>\n<\/p>\n<p><script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"FAQPage\",\n  \"mainEntity\": [\n    {\n      \"@type\": \"Question\",\n      \"name\": \"Can we create an API using node\/express?\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"Yes, you can use Node.js and Express.js to create an API. Express.js is among the famous frameworks to develop an API on top of Node.js.\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"Is express node good for creating a mock API?\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"Yes, express is a popular option for developing mock APIs because of its flexibility and ease of use.\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"Why should you use faux API instead of Node express to mock an API?\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"Building a mock API using Node or Express often involves multiple setup steps. Instead, you can use the \n<a href=\\\"https:\/\/faux-api.com\/instantAPI\\\">Faux Instant API<\/a> to create mock APIs instantly without signup. It provides a simple and efficient way to generate APIs without complex configuration. You can get started quickly and focus on development without additional effort. <a href=\\\"https:\/\/faux-api.com\/instantAPI\/\\\" title=\\\"Start mocking your API today\\\">Start mocking your API today.<\/a>\"\n      }\n    }\n  ]\n}\n<\/script><br \/>\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Effective testing ensures you have developed an application that runs smoothly and meets your users&#8217; expectations. There are many methods you can use in order to test your app. However, mocking API stands out as the perfect method to test an application because it allows you to test your app without relying on live data. <a href=\"https:\/\/faux-api.com\/blogs\/whats-the-best-way-to-mock-an-api-using-app-router\/\" class=\"more-link\">&#8230;<span class=\"screen-reader-text\">What&#8217;s the best way to mock an API using app router?<\/span><\/a><\/p>\n","protected":false},"author":9,"featured_media":188,"comment_status":"open","ping_status":"closed","sticky":false,"template":"specific-blog-details.php","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-167","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-production-api"],"acf":[],"yoast_head":"\n<title>What&#039;s the best way to mock an API using app router?<\/title>\n<meta name=\"description\" content=\"You should mock an API using app router to make this phase more impactful. Read more to know the best way to mock\/faux an API using node\/express server.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/faux-api.com\/blogs\/whats-the-best-way-to-mock-an-api-using-app-router\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What&#039;s the best way to mock an API using app router?\" \/>\n<meta property=\"og:description\" content=\"You should mock an API using app router to make this phase more impactful. Read more to know the best way to mock\/faux an API using node\/express server.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/faux-api.com\/blogs\/whats-the-best-way-to-mock-an-api-using-app-router\/\" \/>\n<meta property=\"og:site_name\" content=\"Faux API Blogs\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/61558493493474\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-08-05T10:24:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-29T06:41:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/faux-api.com\/blogs\/wp-content\/uploads\/2024\/08\/create-mock-api-node-express.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"445\" \/>\n\t<meta property=\"og:image:height\" content=\"314\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Vanessa J. Overstreet\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@FauxAPI\" \/>\n<meta name=\"twitter:site\" content=\"@FauxAPI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Vanessa J. Overstreet\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/whats-the-best-way-to-mock-an-api-using-app-router\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/whats-the-best-way-to-mock-an-api-using-app-router\\\/\"},\"author\":{\"name\":\"Vanessa J. Overstreet\",\"@id\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/#\\\/schema\\\/person\\\/7934f3539a855605d9f0058832c6670e\"},\"headline\":\"What&#8217;s the best way to mock an API using app router?\",\"datePublished\":\"2024-08-05T10:24:02+00:00\",\"dateModified\":\"2026-03-29T06:41:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/whats-the-best-way-to-mock-an-api-using-app-router\\\/\"},\"wordCount\":988,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/whats-the-best-way-to-mock-an-api-using-app-router\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/wp-content\\\/uploads\\\/2024\\\/08\\\/create-mock-api-node-express.jpg\",\"articleSection\":[\"Production API\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/faux-api.com\\\/blogs\\\/whats-the-best-way-to-mock-an-api-using-app-router\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/whats-the-best-way-to-mock-an-api-using-app-router\\\/\",\"url\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/whats-the-best-way-to-mock-an-api-using-app-router\\\/\",\"name\":\"What's the best way to mock an API using app router?\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/whats-the-best-way-to-mock-an-api-using-app-router\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/whats-the-best-way-to-mock-an-api-using-app-router\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/wp-content\\\/uploads\\\/2024\\\/08\\\/create-mock-api-node-express.jpg\",\"datePublished\":\"2024-08-05T10:24:02+00:00\",\"dateModified\":\"2026-03-29T06:41:23+00:00\",\"description\":\"You should mock an API using app router to make this phase more impactful. Read more to know the best way to mock\\\/faux an API using node\\\/express server.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/whats-the-best-way-to-mock-an-api-using-app-router\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/faux-api.com\\\/blogs\\\/whats-the-best-way-to-mock-an-api-using-app-router\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/whats-the-best-way-to-mock-an-api-using-app-router\\\/#primaryimage\",\"url\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/wp-content\\\/uploads\\\/2024\\\/08\\\/create-mock-api-node-express.jpg\",\"contentUrl\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/wp-content\\\/uploads\\\/2024\\\/08\\\/create-mock-api-node-express.jpg\",\"width\":445,\"height\":314,\"caption\":\"create-mock-api-node-express\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/whats-the-best-way-to-mock-an-api-using-app-router\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What&#8217;s the best way to mock an API using app router?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/#website\",\"url\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/\",\"name\":\"Faux API\",\"description\":\"My Faux API Blogs\",\"publisher\":{\"@id\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/#organization\",\"name\":\"Faux API\",\"url\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/wp-content\\\/uploads\\\/2025\\\/02\\\/logo.svg\",\"contentUrl\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/wp-content\\\/uploads\\\/2025\\\/02\\\/logo.svg\",\"width\":\"1024\",\"height\":\"1024\",\"caption\":\"Faux API\"},\"image\":{\"@id\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/61558493493474\\\/\",\"https:\\\/\\\/x.com\\\/FauxAPI\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/faux-api\\\/\",\"https:\\\/\\\/www.instagram.com\\\/faux_api\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/#\\\/schema\\\/person\\\/7934f3539a855605d9f0058832c6670e\",\"name\":\"Vanessa J. Overstreet\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/wp-content\\\/uploads\\\/2025\\\/02\\\/vanessa-overstreet.jpg\",\"url\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/wp-content\\\/uploads\\\/2025\\\/02\\\/vanessa-overstreet.jpg\",\"contentUrl\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/wp-content\\\/uploads\\\/2025\\\/02\\\/vanessa-overstreet.jpg\",\"caption\":\"Vanessa J. Overstreet\"},\"description\":\"Vanessa is a full stack developer with excellent technical skills. She has a profound knowledge of various programming languages and building frontend and backend websites with rich features.\",\"url\":\"https:\\\/\\\/faux-api.com\\\/blogs\\\/author\\\/vanessa-j-overstreet\\\/\"}]}<\/script>\n","yoast_head_json":{"title":"What's the best way to mock an API using app router?","description":"You should mock an API using app router to make this phase more impactful. Read more to know the best way to mock\/faux an API using node\/express server.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/faux-api.com\/blogs\/whats-the-best-way-to-mock-an-api-using-app-router\/","og_locale":"en_US","og_type":"article","og_title":"What's the best way to mock an API using app router?","og_description":"You should mock an API using app router to make this phase more impactful. Read more to know the best way to mock\/faux an API using node\/express server.","og_url":"https:\/\/faux-api.com\/blogs\/whats-the-best-way-to-mock-an-api-using-app-router\/","og_site_name":"Faux API Blogs","article_publisher":"https:\/\/www.facebook.com\/61558493493474\/","article_published_time":"2024-08-05T10:24:02+00:00","article_modified_time":"2026-03-29T06:41:23+00:00","og_image":[{"width":445,"height":314,"url":"https:\/\/faux-api.com\/blogs\/wp-content\/uploads\/2024\/08\/create-mock-api-node-express.jpg","type":"image\/jpeg"}],"author":"Vanessa J. Overstreet","twitter_card":"summary_large_image","twitter_creator":"@FauxAPI","twitter_site":"@FauxAPI","twitter_misc":{"Written by":"Vanessa J. Overstreet","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/faux-api.com\/blogs\/whats-the-best-way-to-mock-an-api-using-app-router\/#article","isPartOf":{"@id":"https:\/\/faux-api.com\/blogs\/whats-the-best-way-to-mock-an-api-using-app-router\/"},"author":{"name":"Vanessa J. Overstreet","@id":"https:\/\/faux-api.com\/blogs\/#\/schema\/person\/7934f3539a855605d9f0058832c6670e"},"headline":"What&#8217;s the best way to mock an API using app router?","datePublished":"2024-08-05T10:24:02+00:00","dateModified":"2026-03-29T06:41:23+00:00","mainEntityOfPage":{"@id":"https:\/\/faux-api.com\/blogs\/whats-the-best-way-to-mock-an-api-using-app-router\/"},"wordCount":988,"commentCount":0,"publisher":{"@id":"https:\/\/faux-api.com\/blogs\/#organization"},"image":{"@id":"https:\/\/faux-api.com\/blogs\/whats-the-best-way-to-mock-an-api-using-app-router\/#primaryimage"},"thumbnailUrl":"https:\/\/faux-api.com\/blogs\/wp-content\/uploads\/2024\/08\/create-mock-api-node-express.jpg","articleSection":["Production API"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/faux-api.com\/blogs\/whats-the-best-way-to-mock-an-api-using-app-router\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/faux-api.com\/blogs\/whats-the-best-way-to-mock-an-api-using-app-router\/","url":"https:\/\/faux-api.com\/blogs\/whats-the-best-way-to-mock-an-api-using-app-router\/","name":"What's the best way to mock an API using app router?","isPartOf":{"@id":"https:\/\/faux-api.com\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/faux-api.com\/blogs\/whats-the-best-way-to-mock-an-api-using-app-router\/#primaryimage"},"image":{"@id":"https:\/\/faux-api.com\/blogs\/whats-the-best-way-to-mock-an-api-using-app-router\/#primaryimage"},"thumbnailUrl":"https:\/\/faux-api.com\/blogs\/wp-content\/uploads\/2024\/08\/create-mock-api-node-express.jpg","datePublished":"2024-08-05T10:24:02+00:00","dateModified":"2026-03-29T06:41:23+00:00","description":"You should mock an API using app router to make this phase more impactful. Read more to know the best way to mock\/faux an API using node\/express server.","breadcrumb":{"@id":"https:\/\/faux-api.com\/blogs\/whats-the-best-way-to-mock-an-api-using-app-router\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/faux-api.com\/blogs\/whats-the-best-way-to-mock-an-api-using-app-router\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/faux-api.com\/blogs\/whats-the-best-way-to-mock-an-api-using-app-router\/#primaryimage","url":"https:\/\/faux-api.com\/blogs\/wp-content\/uploads\/2024\/08\/create-mock-api-node-express.jpg","contentUrl":"https:\/\/faux-api.com\/blogs\/wp-content\/uploads\/2024\/08\/create-mock-api-node-express.jpg","width":445,"height":314,"caption":"create-mock-api-node-express"},{"@type":"BreadcrumbList","@id":"https:\/\/faux-api.com\/blogs\/whats-the-best-way-to-mock-an-api-using-app-router\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/faux-api.com\/blogs\/"},{"@type":"ListItem","position":2,"name":"What&#8217;s the best way to mock an API using app router?"}]},{"@type":"WebSite","@id":"https:\/\/faux-api.com\/blogs\/#website","url":"https:\/\/faux-api.com\/blogs\/","name":"Faux API","description":"My Faux API Blogs","publisher":{"@id":"https:\/\/faux-api.com\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/faux-api.com\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/faux-api.com\/blogs\/#organization","name":"Faux API","url":"https:\/\/faux-api.com\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/faux-api.com\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/faux-api.com\/blogs\/wp-content\/uploads\/2025\/02\/logo.svg","contentUrl":"https:\/\/faux-api.com\/blogs\/wp-content\/uploads\/2025\/02\/logo.svg","width":"1024","height":"1024","caption":"Faux API"},"image":{"@id":"https:\/\/faux-api.com\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/61558493493474\/","https:\/\/x.com\/FauxAPI","https:\/\/www.linkedin.com\/company\/faux-api\/","https:\/\/www.instagram.com\/faux_api\/"]},{"@type":"Person","@id":"https:\/\/faux-api.com\/blogs\/#\/schema\/person\/7934f3539a855605d9f0058832c6670e","name":"Vanessa J. Overstreet","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/faux-api.com\/blogs\/wp-content\/uploads\/2025\/02\/vanessa-overstreet.jpg","url":"https:\/\/faux-api.com\/blogs\/wp-content\/uploads\/2025\/02\/vanessa-overstreet.jpg","contentUrl":"https:\/\/faux-api.com\/blogs\/wp-content\/uploads\/2025\/02\/vanessa-overstreet.jpg","caption":"Vanessa J. Overstreet"},"description":"Vanessa is a full stack developer with excellent technical skills. She has a profound knowledge of various programming languages and building frontend and backend websites with rich features.","url":"https:\/\/faux-api.com\/blogs\/author\/vanessa-j-overstreet\/"}]}},"_links":{"self":[{"href":"https:\/\/faux-api.com\/blogs\/wp-json\/wp\/v2\/posts\/167","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/faux-api.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/faux-api.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/faux-api.com\/blogs\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/faux-api.com\/blogs\/wp-json\/wp\/v2\/comments?post=167"}],"version-history":[{"count":37,"href":"https:\/\/faux-api.com\/blogs\/wp-json\/wp\/v2\/posts\/167\/revisions"}],"predecessor-version":[{"id":818,"href":"https:\/\/faux-api.com\/blogs\/wp-json\/wp\/v2\/posts\/167\/revisions\/818"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/faux-api.com\/blogs\/wp-json\/wp\/v2\/media\/188"}],"wp:attachment":[{"href":"https:\/\/faux-api.com\/blogs\/wp-json\/wp\/v2\/media?parent=167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/faux-api.com\/blogs\/wp-json\/wp\/v2\/categories?post=167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/faux-api.com\/blogs\/wp-json\/wp\/v2\/tags?post=167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}