1.5.14 • Published 9 months ago
@cimo/request v1.5.14
Request
Npm package, request api. Light, fast and secure. Writed with native Typescript code and no dependencies are used.
Pack
- npm run pack
- Copy the file "package_name-x.x.x.tgz" in the project root folder.
- In the "package.json" file insert: "@cimo/package_name": "file:package_name-x.x.x.tgz"
Publish
- npm run build
- npm login --auth-type=legacy
- npm publish --auth-type=legacy --access public
Installation
- Link for npm package -> https://www.npmjs.com/package/@cimo/request
Info
Support the encoding if your application have some firewall like "azure waf". The request body will be fully encoded and from backend need be decoded and processed. By default is "false".
Client
- Client.ts
...
import { Cr } from "@cimo/request";
...
const cr = new Cr("https://localhost", 25000, false);
cr.setRequestInterceptor((config) => {
//...
return {
...config,
headers: {
...config.headers,
"Accept-Language": "en,ja;q=0.9"
}
};
});
cr.setResponseInterceptor((response) => {
if (response.ok) {
// Success
} else {
// Fail
}
});
...
const data = {
token_api: "1234",
name: "test",
};
const formData = new FormData();
formData.append("token_api", "1234");
formData.append("name", "test");
// use formData with "multipart/form-data" or in case of file upload, just remove the headers content-type.
cr.post("/test_post",
{
headers: {
"Content-Type": "application/json"
}
},
data
)
.then((data) => {
// Response
})
.catch((error) => {
// Error
});
cr.get("/test_get", {})
.then((data) => {
// Response
})
.catch((error) => {
// Error
});
// put, delete, patch
...
1.4.11
12 months ago
1.5.14
9 months ago
1.4.13
9 months ago
1.5.13
9 months ago
1.4.12
11 months ago
1.4.9
1 year ago
1.4.10
1 year ago
1.4.8
2 years ago
1.4.7
2 years ago
1.4.6
2 years ago
1.4.5
2 years ago
1.4.4
2 years ago
1.3.4
2 years ago
1.2.4
2 years ago
1.2.3
2 years ago
1.2.2
2 years ago
1.1.2
2 years ago
1.1.1
2 years ago
1.0.0
2 years ago