[Next.js] Create an API Route Using the next-connect Package
2023-09-14 08:59:12 时间
We'll learn an alternative way of creating API routes using the next-connect package. next-connect gives us an alternative that would feel familiar to anyone that has worked with Express in the past.
- https://github.com/hoangvvo/next-connect
import nextConnect from "next-connect" const handler = nextConnect({ onNoMatch: (req, res) => res.status(404).json({message: 'not found'}) }) .get((req, res) => res.status(200).json({message: 'GET!'})) .post((req, res) => res.status(200).json({message: 'POST!'})) .patch((req, res) => res.status(200).json({message: 'PATCH!'})) .put((req, res) => res.status(200).json({message: 'PUT!'})) .delete((req, res) => res.status(200).json({message: 'DELETE!'})) export default handler
相关文章
- js 中的submit 回调函数
- JS框架_(JQuery.js)网页文字评论弹幕
- JS框架_(JQbar.js)柱状图动态百分比进度条特效
- ABP源码分析三十七:ABP.Web.Api Script Proxy API
- 如何查看jsplumb.js的API文档(YUIdoc的基本使用)#华为云·寻找黑马程序员#
- JS - 解决引入 js 文件无效的问题
- js对象与字符串相互转换
- js中的children实时获取子元素
- ERROR in index.web.js from UglifyJs
- html5.js
- [Next.js] Hide Sensitive Information from the Consumers of Next.js API
- [Node.js] Mock an API for Local Development in React with Mirage JS
- [Node.js] Reading from the File System in Node.js
- [Mise] Refetch API data when a state value changes with the `$watch` property in Alpine JS
- [Next.js] Consume Next.js API routes with the SWR library on the client-side
- [Vue-rx] Stream an API using RxJS into a Vue.js Template
- Atitit Persistence API持久性标准化法总结 目录 1. 持久性对于大多数企业应用程序都非常要害1 2. 持久化api内容2 2.1. 一种声明式地执行O-R映射的方式。2
- Atitit.跨语言 java c#.net php js常用的codec encode算法api 兼容性 应该内置到语言里面
- atitit.跨语言实现备份mysql数据库 为sql文件特性 api 兼容性java c#.net php js
- Atitit.跨平台预定义函数 魔术方法 魔术函数 钩子函数 api兼容性草案 v2 q216 java c# php js.docx
- atitit.js javascript 调用c# java php后台语言api html5交互的原理与总结p97
- 手机移动端返回顶部js代码demo效果示例(整理)
- Unity3D中C#和JS的方法互相調用
- JS:crypto-js模块实现数据加密解密
- JS:使用Mock.js生成随机数据,拦截 Ajax 请求
- babel配置项目目录支持转换es6语法,引入非项目目录js后,引入Js转换无效
- 前端基础 & 初识JS(JavaScript)
- 很easy的js双向绑定框架(二):控制器继承
- 利用js_API 运行对html文档元素的属性的CRUD操作
- 【JS高级】js之闭包对象_04
- js删除数组中第一个元素方法总结