test.mjs 883 B

12345678910111213141516171819202122232425262728293031
  1. import axios from "axios";
  2. const testChartGeneration = async () => {
  3. try {
  4. // 测试数据URL
  5. // const dataUrl = "http://127.0.0.1:3000/testData.json";
  6. const dataUrl =
  7. "http://192.168.50.233:6900/wof039800012/WOF039800012-WOB000001/wind_speed_frequency/manual/wind_Speed_Frequency%2303.json";
  8. console.log("开始测试图表生成...");
  9. // 发送请求生成图表
  10. const response = await axios.post("http://127.0.0.1:3000/api/charts/bar", {
  11. dataUrl: dataUrl,
  12. });
  13. console.log("图表生成成功!");
  14. console.log("响应数据:", response.data);
  15. console.log(
  16. "图表URL:",
  17. `http://127.0.0.1:3000${response.data.data.imageUrl}`,
  18. );
  19. } catch (error) {
  20. console.error(
  21. "测试失败:",
  22. error.response ? error.response.data : error.message,
  23. );
  24. }
  25. };
  26. // 运行测试
  27. // testChartGeneration();