-
Notifications
You must be signed in to change notification settings - Fork 2
Key verification
Key verification authenticates your API key before calling the comment check, submit spam or submit ham methods.
Client.verifyKey(): Promise<boolean>
This is the first call that you should make to Akismet and is especially useful if you will have multiple users with their own Akismet subscriptions using your application.
See the Akismet API documentation for more information.
None.
A Promise
that resolves with a boolean value indicating whether the client's API key is valid.
The promise rejects with an Error
when an issue occurs.
The error message
usually includes some debug information, provided by the X-akismet-debug-help
HTTP header,
about what exactly was invalid about the call.
It can also reject with a custom error code and message (respectively provided by the X-akismet-alert-code
and X-akismet-alert-msg
headers).
See Response Error Codes for more information.
import console from "node:console";
import {Blog, Client} from "@cedx/akismet";
try {
const blog = new Blog({url: "https://www.yourblog.com"});
const client = new Client("123YourAPIKey", blog);
const isValid = await client.verifyKey();
console.log(isValid ? "The API key is valid." : "The API key is invalid.");
}
catch (error) {
console.log(error instanceof Error ? error.message : error);
}
See the source code for detailed information
about the Client
and Blog
classes, and their properties and methods.