1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | // 1. 安装 axios(如果未安装) // 在终端执行: npm install axios const axios = require( 'axios' ); // 2. 直接配置参数 const url = 'https://api.jisuapi.com/calendar/query' ; const params = { appkey: 'your_appkey_here' , // 替换成你的真实appkey islunar: 0, islunarmonth: 0 }; // 3. 立即发送请求 axios.get(url, { params }) .then(response => { // 检查API业务状态码 if (response.data.status !== 0) { console.error( 'API返回错误:' , response.data.status+ "-" +response.data.msg); return ; } // 输出结果 // 基本信息 for (const [key, value] of Object.entries(response.data.result)) { if ( typeof value !== 'object' ) { console.log(`${key}: ${value}`); } } // 黄历信息 for (const [key_hl, value_hl] of Object.entries(response.data.result.huangli)) { console.log(`${key_hl}: ${value_hl}`); } }) . catch (error => { // 统一错误处理 console.error( '请求失败!' ); }); |
© 2015-2025 杭州极速互联科技有限公司 版权所有 浙ICP备17047587号-4 浙公网安备33010502005096 增值电信业务经营许可证:浙B2-20190875