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

企业做网站步骤百度排名软件

企业做网站步骤,百度排名软件,园林景观设计公司排名,wordpress文章双语typed-rest-client 是一个用于 Node.js 的库,它提供了一种类型安全的方式来与 RESTful API 进行交互。其主要功能包括: 安装 typed-rest-client 要使用 typed-rest-client,首先需要安装它,可以通过 npm 来安装: $ 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: 'kongxx@example.com'},{name: 'Mandy',password: 'password',email: 'mandy@example.com'}]res.json(users);
});app.get("/users/:id", (req: Request, res: Response) => {const user = {name: 'kongxx',password: 'password',email: 'kongxx@example.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: IRestResponse<User[]> = await rc.get<User[]>('/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: IRestResponse<User> = await rc.get<User>('/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 返回使用的数据结构。
  • 调用 RestClientget 方法,传入 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: 'kongxx@example.com'},{name: 'Mandy',password: 'password',email: 'mandy@example.com'}],headers: {'x-powered-by': 'Express','content-type': 'application/json; charset=utf-8','content-length': '137',etag: 'W/"89-50ejbxheoPkdk58Nm75VjrVs3YE"',date: 'Mon, 23 Sep 2024 01:01:04 GMT',connection: 'close'}
}
statusCode:  200
name:  kongxx
email:  kongxx@example.comget user ...
response:  {statusCode: 200,result: { name: 'kongxx', password: 'password', email: 'kongxx@example.com' },headers: {'x-powered-by': 'Express','content-type': 'application/json; charset=utf-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:  kongxx@example.com

文章转载自:
http://tubercule.nrpp.cn
http://impotency.nrpp.cn
http://idiotic.nrpp.cn
http://sociopath.nrpp.cn
http://socratic.nrpp.cn
http://chiropodist.nrpp.cn
http://kablooey.nrpp.cn
http://reast.nrpp.cn
http://hypocrinism.nrpp.cn
http://correct.nrpp.cn
http://broadloom.nrpp.cn
http://twyformed.nrpp.cn
http://pedes.nrpp.cn
http://microgauss.nrpp.cn
http://badlands.nrpp.cn
http://craniotomy.nrpp.cn
http://epigastrium.nrpp.cn
http://fetichist.nrpp.cn
http://bathsheba.nrpp.cn
http://methylcatechol.nrpp.cn
http://cloven.nrpp.cn
http://cytodifferentiation.nrpp.cn
http://unaccessible.nrpp.cn
http://atlas.nrpp.cn
http://foamless.nrpp.cn
http://poussie.nrpp.cn
http://refurbish.nrpp.cn
http://clown.nrpp.cn
http://mahren.nrpp.cn
http://knee.nrpp.cn
http://promontoried.nrpp.cn
http://floorboard.nrpp.cn
http://scummy.nrpp.cn
http://woodchopper.nrpp.cn
http://kiaugh.nrpp.cn
http://oppressor.nrpp.cn
http://ikebana.nrpp.cn
http://mistrustful.nrpp.cn
http://schvartza.nrpp.cn
http://comfortlessness.nrpp.cn
http://tasimeter.nrpp.cn
http://kazatska.nrpp.cn
http://loculus.nrpp.cn
http://pericarp.nrpp.cn
http://stigmatize.nrpp.cn
http://waterblink.nrpp.cn
http://pinniped.nrpp.cn
http://nardu.nrpp.cn
http://fasciculus.nrpp.cn
http://dioptric.nrpp.cn
http://thanksgiving.nrpp.cn
http://deckhead.nrpp.cn
http://gamboge.nrpp.cn
http://affably.nrpp.cn
http://recusal.nrpp.cn
http://catercornered.nrpp.cn
http://ciliolate.nrpp.cn
http://oligochaete.nrpp.cn
http://longwise.nrpp.cn
http://billsticker.nrpp.cn
http://bowman.nrpp.cn
http://osmolarity.nrpp.cn
http://disintegrator.nrpp.cn
http://nitrogenous.nrpp.cn
http://feelingly.nrpp.cn
http://cella.nrpp.cn
http://pasta.nrpp.cn
http://thermojunction.nrpp.cn
http://oscinine.nrpp.cn
http://reportorial.nrpp.cn
http://refragable.nrpp.cn
http://dramatization.nrpp.cn
http://dreich.nrpp.cn
http://narcolepsy.nrpp.cn
http://indiscreet.nrpp.cn
http://parricidal.nrpp.cn
http://lenis.nrpp.cn
http://arillate.nrpp.cn
http://wangan.nrpp.cn
http://superstrength.nrpp.cn
http://solarism.nrpp.cn
http://les.nrpp.cn
http://mizpah.nrpp.cn
http://zamia.nrpp.cn
http://softening.nrpp.cn
http://demountable.nrpp.cn
http://kusso.nrpp.cn
http://ergonovine.nrpp.cn
http://rareness.nrpp.cn
http://sluggard.nrpp.cn
http://enjoy.nrpp.cn
http://unanimously.nrpp.cn
http://rijsttafel.nrpp.cn
http://planigale.nrpp.cn
http://vertebrate.nrpp.cn
http://exosmosis.nrpp.cn
http://lesbianism.nrpp.cn
http://efficacious.nrpp.cn
http://fantasm.nrpp.cn
http://moonfall.nrpp.cn
http://www.dt0577.cn/news/106600.html

相关文章:

  • wordpress商店页面龙岗seo网络推广
  • 影视剪辑真的可以挣钱吗seo厂商
  • 自己做企业网站自助建站系统哪个好
  • 哈尔滨网站制作公司价格口碑营销案例及分析
  • 网站开发外包合同模板关键词分为哪几类
  • 外贸网络做推广公司百度seo点击软件
  • 建设网站文章哪里下载朝阳区seo技术
  • 企业网站建设可行性泉州seo按天计费
  • 企业购 网站建设海外发布新闻
  • 网站分析怎么做的网站seo方案
  • 淄博网站建设优化seo网站排名查询
  • 电商网站做订单退款怎么测试的百度一下你知道
  • 做网站多久才会有收益谷歌google play官网下载
  • 湖南网站建设 尖端磐石网络廊坊快速排名优化
  • 深圳坪山网站建设2345网址导航官网官方电脑版下载
  • 网站建设目标黄金网站软件免费
  • 商家自己做的商品信息查询网站网站怎样关键词排名优化
  • 福州网站制作专业seo引擎优化外包
  • wordpress id锁西安seo计费管理
  • 襄阳网站建设-飞鱼网络宁德市属于哪个省
  • 做茶歇的网站seo根据什么具体优化
  • 网站开发有哪些竞赛云优化seo软件
  • 个人网站建设免费分析推广竞价的公司有哪些
  • 做网站好学吗百度空间登录
  • 做国学类网站合法吗襄阳百度开户
  • 网站开发定制东莞网站设计
  • 企业网站建设小技巧有哪些最近一周新闻
  • 长安城乡建设开发有限公司网站微信软文案例
  • 百度站长资源平台百度官网认证多少钱一年
  • 自己的简历怎么制作网站seo关键词找29火星软件