Search.../

notFound( )

Returns a response with status code 404 (Not Found) and the information from the options parameter.

Description

The notFound() function creates a response with the status code 404 (Not Found).

Optionally, the notFound() function can take a WixHttpFunctionResponseOptions object which is used to specify the response's body and headers. If the object contains a status it will be ignored.

Use the notFound() function to create a response to return from an HTTP function. A 404 (Not Found) response is usually used to indicate that the requested resource was not found at the current time.

Syntax

function notFound(options: WixHttpFunctionResponseOptions): WixHttpFunctionResponse

notFound Parameters

NAME
TYPE
DESCRIPTION
options

WixHttpFunctionResponseOptions

The response options.

Returns

Was this helpful?

Create a 404 (Not Found) response

Code Example

Copy Code
1// In http-functions.js
2
3import {notFound} from 'wix-http-functions';
4
5export function use_myFunction(request) {
6
7 return notFound();
8}
Create a 404 (Not Found) response

Code Example

Copy Code
1// In http-functions.js
2
3import {notFound} from 'wix-http-functions';
4
5export function use_myFunction(request) {
6
7 let options = {
8 body: {
9 "error": "not found"
10 },
11 headers: {
12 "Content-Type": "application/json"
13 }
14 };
15
16 return notFound(options);
17}