当前位置: 首页 > news >正文

那个网站教做仙芋鲜怎样做推广更有效

那个网站教做仙芋鲜,怎样做推广更有效,dede网站婚纱模板,绿色网站模板大全typed-rest-client 是一个用于 Node.js 的库#xff0c;它提供了一种类型安全的方式来与 RESTful API 进行交互。其主要功能包括#xff1a; 安装 typed-rest-client 要使用 typed-rest-client#xff0c;首先需要安装它#xff0c;可以通过 npm 来安装#xff1a; $ n…typed-rest-client 是一个用于 Node.js 的库它提供了一种类型安全的方式来与 RESTful API 进行交互。其主要功能包括 安装 typed-rest-client 要使用 typed-rest-client首先需要安装它可以通过 npm 来安装 $ npm install typed-rest-client使用 typed-rest-client 这里假定有个 express 的 server 提供了两个 REST API一个是获取用户列表一个是获取用户信息。 index.ts import express, { Express, Request, Response } from express;const app: Express express(); const port process.env.PORT || 3000;app.get(/, (req: Request, res: Response) {res.send(Express TypeScript Server); });app.get(/users, (req: Request, res: Response) {const users [{name: kongxx,password: password,email: kongxxexample.com},{name: Mandy,password: password,email: mandyexample.com}]res.json(users); });app.get(/users/:id, (req: Request, res: Response) {const user {name: kongxx,password: password,email: kongxxexample.com}res.json(user); });app.listen(port, () {console.log([server]: Server is running at http://localhost:${port}); });下面是测试程序 test.ts import {RestClient, IRestResponse} from typed-rest-client/RestClient;interface User {name: string;password: string;email: string; }async function test() {const rc: RestClient new RestClient(test, http://localhost:3000);const resUsers: IRestResponseUser[] await rc.getUser[](/users);console.log(get users ...);console.log(response: , resUsers);console.log(statusCode: , resUsers.statusCode);console.log(name: , resUsers.result[0]?.name);console.log(email: , resUsers.result[0]?.email);const resUser: IRestResponseUser await rc.getUser(/users/1);console.log(get user ...);console.log(response: , resUser);console.log(statusCode: , resUser.statusCode);console.log(name: , resUser.result?.name);console.log(email: , resUser.result?.email); }test();这里首先定义了一个 interface描述了 REST API 返回使用的数据结构。调用 RestClient 的 get 方法传入 URL 和返回的数据类型返回一个 IRestResponse 对象IRestResponse 对象包含了 HTTP 响应的状态码、响应头和响应体。通过 statusCode 属性可以获取到 HTTP 响应的状态码。通过 headers 属性可以获取到 HTTP 响应头。通过 result 属性可以获取到响应体中的数据。 测试 首先启动express server。 $ npm run dev运行测试程序 $ npm install -g typescript $ tsc src/test.ts node src/test.jsget users ... response: {statusCode: 200,result: [{name: kongxx,password: password,email: kongxxexample.com},{name: Mandy,password: password,email: mandyexample.com}],headers: {x-powered-by: Express,content-type: application/json; charsetutf-8,content-length: 137,etag: W/89-50ejbxheoPkdk58Nm75VjrVs3YE,date: Mon, 23 Sep 2024 01:01:04 GMT,connection: close} } statusCode: 200 name: kongxx email: kongxxexample.comget user ... response: {statusCode: 200,result: { name: kongxx, password: password, email: kongxxexample.com },headers: {x-powered-by: Express,content-type: application/json; charsetutf-8,content-length: 68,etag: W/44-WML8FV1wUhoW//8kQuCB8B/FWaQ,date: Mon, 23 Sep 2024 01:01:04 GMT,connection: close} } statusCode: 200 name: kongxx email: kongxxexample.com
http://www.dnsts.com.cn/news/114743.html

相关文章:

  • 柳州团购汽车网站建设做一个企业的网站怎么做的
  • 建筑行业数据共享平台网站自己做网站可以赚钱吗
  • 网站建设费怎么做会计分录关于电商网站建设与管理的书籍
  • 天津网站建设公司最好深圳市设计网站
  • 做网站是不是需要服务器免费商标图案 创意
  • 石狮住房和城乡建设网站蛋糕店网站模板
  • 特色的佛山网站建设wordpress插件点不开
  • 兰州微网站知名企业网站搭建新感觉全网价值营销服务商
  • 网站建设费用 多少html网站支付链接怎么做的
  • 做茶叶网站的目的和规划长春网站制作方案定制
  • 保定网页模板建站崂山区建设局网站
  • 网上购物网站开发英文文献网络营销方法有哪几种
  • 网站pc和手机端分离怎么做小程序制作要求
  • 常州市建设工程交易网网站seo优化很好徐州百都网络点赞
  • wap网站发布百度推广售后电话
  • 韩国ps教程网站湛江仿站定制模板建站
  • 网站权重降低仓库盘点网站开发
  • 官方网站怎么备案想要黑掉一个网站 要怎么做
  • 足球网站模板网站设置文件夹权限
  • 目前网页设计工资多少宁德seo推广
  • 武平县网站建设建文帝网站建设
  • 淘宝关键词排名查询网站门户网站系统建设项目投标书
  • 无锡做网站6可拖拽式网站建设
  • 网站建设商城制作搜索引擎优化涉及的内容
  • wordpress调用菜单代码河南seo推广
  • ppt网站学做网站能赚钱吗
  • 黄浦网站设计网站设计美工多少
  • 武威网站建设价格wordpress语言文件
  • 东莞外贸企业做网站手机微网站平台登录入口
  • 设计素材网站需要多大服务器wordpress 安装不了