getPostMetrics( )


Gets a specified post's metrics.

The getPostMetrics() function returns a Promise that resolves to the specified post's metrics.

A post's metrics include the comments, likes, and views the post receives.

Permissions
Read Blog
Manage Blog
Read Draft Blog Posts
Learn more about app permissions.
Method Declaration
Copy
function getPostMetrics(postId: string): Promise<GetPostMetricsResponse>;
Method Parameters
postIdstringRequired

Post ID.

Returns
Return Type:Promise<GetPostMetricsResponse>
JavaScript
import { posts } from "wix-blog-backend"; /* Sample postId value: * 'ccbb6257-ed0e-4521-97df-8b5b207adb00' */ export async function getPostMetricsFunction(postId) { try { const result = await posts.getPostMetrics(postId); const likes = result.metrics.likes; console.log("Retrieved Result:", result); return result; } catch (error) { console.log(error); } } /* Promise resolves to: * { * "metrics": { * "comments": 8, * "likes": 20, * "views": 2 * } * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?