getTagByLabel( )


Gets a tag by the specified label.

The getTagByLabel() function returns a Promise that resolves to a tag whose label matches the specified label.

Permissions
Read Blog
Manage Blog
Read Draft Blog Posts
Learn more about app permissions.
Method Declaration
Copy
function getTagByLabel(
  label: string,
  options: GetTagByLabelOptions,
): Promise<GetTagByLabelResponse>;
Method Parameters
labelstringRequired

Tag label.


optionsGetTagByLabelOptions

Options specifying which additional fields to return.

Returns
Return Type:Promise<GetTagByLabelResponse>
JavaScript
import { tags } from "wix-blog-backend"; /* Sample label value: * 'my tag' */ export async function getTagByLabelFunction(tagId) { try { const result = await tags.getTagByLabel(tagId); const label = result.tag.label; const postCount = result.tag.postCount; console.log("Retrieved result:", result); return result; } catch (error) { console.error(error); } } /* Promise resolves to: * { * "tag": { * "_createdDate": "2022-07-19T10:30:03.607Z", * "_id": "32970480-e53b-46e7-b52f-fba810a0b45d", * "_updatedDate": "2022-07-19T10:30:03.607Z", * "label": "my tag", * "language": "en", * "postCount": 1, * "publishedPostCount": 1, * "slug": "my-tag", * "translationId": "" * } * } */
Errors

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

Did this help?