quick fetch api
v2.0.0 Release
Quick-Fetch-API是一个简约的HTTP客户端,旨在轻松和异步请求。它提供了直接的界面,简化了HTTP操作,以获得无缝的开发人员体验。
EasyFetch类,用于处理HTTP请求的更用户友好的方法。 使用NPM安装软件包:
npm install quick-fetch-api const EasyFetch = require ( 'quick-fetch-api' ) ;
// Example usage
const apiUrl = 'https://api.example.com' ;
const api = new EasyFetch ( apiUrl , {
'Content-Type' : 'application/json' ,
// Add headers if any
} ) ;
// GET request example
api . get ( {
url : '/data' ,
callback : ( { loading , data , error } ) => {
if ( loading ) {
console . log ( 'Loading...' ) ;
} else if ( data ) {
console . log ( 'Data:' , data ) ;
} else {
console . error ( 'Error:' , error ) ;
}
} ,
} ) ;
// POST request example
const postData = { key : 'value' } ;
api . post ( {
url : '/create' ,
data : postData ,
callback : ( { loading , data , error } ) => {
if ( loading ) {
console . log ( 'Loading...' ) ;
} else if ( data ) {
console . log ( 'Response:' , data ) ;
} else {
console . error ( 'Error:' , error ) ;
}
} ,
} ) ;
// {like that you can do PUT,PATCH,DELETE} 该项目是根据MIT许可证获得许可的 - 有关详细信息,请参见许可证文件。
根据您的特定项目详细信息,请随时修改或进一步增强它。