nad-runtime ·
The runtime lib of the Nad project.
Include
yarn add @huolala-tech/nad-runtime
or
npm install @huolala-tech/nad-runtime --save
Useage
1. @PathVariable
import { NadInvoker } from '@huolala-tech/nad-runtime';
const getUserInfo = async () => {
return await new NadInvoker('http://localhost').open('GET', '/users/{id}').addPathVariable('id', 123).execute();
};
2. @RequestParam
import { NadInvoker } from '@huolala-tech/nad-runtime';
const getUserInfo = async () => {
return await new NadInvoker('http://localhost').open('GET', '/getUser').addRequestParam('id', id).execute();
};
2. @ModelAttribute
import { NadInvoker } from '@huolala-tech/nad-runtime';
const getUserInfo = async () => {
return await new NadInvoker('http://localhost')
.open('GET', '/getUser')
.addModelAttribute({ id: 1, type: 2 })
.execute();
};
4. @RequestBody
import { NadInvoker } from '@huolala-tech/nad-runtime';
const getUserInfo = async () => {
return await new NadInvoker('http://localhost').open('POST', '/userService').addRequestBody({ id: 123 }).execute();
};