Skip to main content
Version: 3.27.2

toString

info

This method is deprecated, use Backend.prototype.name instead.

The toString() method returns a string representing the specified Backend value.

Syntax

toString()

Return value

A string representing the specified Backend value.

Description

The Backend object overrides the toString() method of Object; it does not inherit Object.prototype.toString(). For Backend values, the toString method returns the name given to the Backend object during construction.

The toString() method requires its this value to be a Backend object.

If the this value does not inherit from Backend.prototype, a TypeError is thrown.

Examples

Using toString()

The following example logs the string value of a Backend object:

import { Backend } from "fastly:backend";
async function app() {
const backend = new Backend({
name: "fastly",
target: "fastly.com",
});
console.log(backend.toString()); // "fastly"
}
addEventListener("fetch", event => event.respondWith(app(event)));