kibana-plugin-development-tutorial
  • Introduction
  • 初识
    • 前言
    • 注意事项
    • kibana开发环境搭建
    • 插件资源
  • 快速入门
    • Hello World
    • 模板工具
    • visTypes插件案例
    • app插件案例
  • 高级进阶
    • UI Exports
    • 与ElasticSearch通信API
    • 自定义配置
    • 前后端通信
    • EUI使用
    • Server端log使用
    • Angularjs架构插件开发
    • React架构插件开发
    • visTypes高级进阶
  • 尾章
    • 开发问题汇总
    • 更多插件列表
Powered by GitBook
On this page
  • server端
  • 初始化
  • 构建路由
  • angularjs
  • react
  1. 高级进阶

前后端通信

这里的前后端通信指的是kibana插件server端与client端通信。一般都是http请求,本章讲解angulajs与react两种模式下通信如何编写。

server端

在index.js初始化server端代码

初始化

    import serverRoute from './server/routes/server';
    init(server, options) {
      // Add server routes and initialize the plugin here
      serverRoute(server, options);
  });

构建路由

在serverRoute.js中新增如下方法

export default function (server) {
  server.route({
    path: '/api/cleaner/_stats',
    method: 'GET',
    handler(req, reply) {
      reply({"message":"Hello World!"});
    }
  });
}

angularjs

   $http
      .get('../api/cleaner/_stats')
      .then((response) => {
          console.log(response);
      });

react

使用axios实现http通信

import axios from 'axios';
const { data } = await axios('../api/cleaner/_stats');
Previous自定义配置NextEUI使用

Last updated 6 years ago