bru.visualize function. This feature supports multiple providers and formats to help you analyze and present your API data effectively.
- type: The type of visualization to render (e.g., ‘table’, ‘html’).
-
config: A configuration object that includes:
- name: The name of the visualization instance.
- provider: The rendering library or provider used to display the visualization (e.g., ‘ag-grid’, ‘react-table’).
- props: Additional properties required by the provider to configure the visualization.
Supported Visualization Types and Providers
Table Visualization (‘table’)
You can render tables using different providers likeag-grid and react-table.
Using ag-grid
Example:
copy
Using react-table
Example:
copy
The
header property only accepts string values. Use strings like header: "Column Name".HTML Visualization (‘html’)
You can also render custom HTML content using the html type. This allows for advanced templating and formatting, such as generating a data table or a report.Using HTML String
Example:
copy
Using API Response Data
One of the most powerful features ofbru.visualize is the ability to transform API responses into visual tables. Here are practical examples of working with real API data:
In Bruno, the parsed API response is stored in res.body
Example 1: Simple User List API
For an API that returns a list of users:copy
Example 2: Nested API Response Data
For APIs returning nested objects, you can flatten the data before visualization:copy
Example 3: Transforming Complex Data
For complex responses that need transformation before visualization:copy
Example 4: Error Handling with API Data
Always include error handling when working with API responses:copy
- Always verify the response structure before accessing nested properties
- Use optional chaining (
?.) to safely access nested data - Transform data to match your visualization needs
- Add meaningful column headers using the
fieldproperty - Enable filters for better data exploration
Using API Response Data with HTML
You can dynamically generate HTML from API responses:copy
Custom Dashboard with Statistics
Create rich dashboards with API data:copy
Viewing Your Visualization
- Add the visualization code to your request’s script section
- Execute the request
- Your visualization will be displayed in the panel
