/
index.md
46 lines (31 loc) · 1.24 KB
/
index.md
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
41
42
43
44
45
46
---
title: ReportBody
slug: Web/API/ReportBody
page-type: web-api-interface
browser-compat: api.ReportBody
---
{{APIRef("Reporting API")}}
The **`ReportBody`** interface of the {{domxref('Reporting API','','',' ')}} represents the body of a report. Individual report types inherit from this interface, adding specific attributes relevant to the particular report.
### Reports that inherit from `ReportBody`
- {{domxref("CSPViolationReportBody")}}
- {{domxref("DeprecationReportBody")}}
- {{domxref("InterventionReportBody")}}
An instance of `ReportBody` is returned as the value of {{domxref("Report.body")}}. The interface has no constructor.
## Instance methods
- {{domxref("ReportBody.toJSON()")}}
- : A _serializer_ which returns a JSON representation of the `ReportBody` object.
## Examples
In this example we create a new {{domxref("ReportingObserver")}} to observe intervention reports. The {{domxref("InterventionReportBody")}} interface inherits from `ReportBody`.
```js
const options = {
types: ["intervention"],
buffered: true,
};
const observer = new ReportingObserver(([firstReport], observer) => {
console.log(firstReport.type); // intervention
}, options);
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}