Skip to content

Commit

Permalink
Merge pull request #193 from benjiwheeler/clarify-http-endpoint
Browse files Browse the repository at this point in the history
clarify that only http vals have and endpoint, and how to find it
  • Loading branch information
maxmcd authored Aug 29, 2024
2 parents c323f8f + fba53ef commit c83eeaa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/content/docs/types/http/basic-examples.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ sidebar:

import Val from "@components/Val.astro";

A val that works with the Web API takes a Request object as input and needs to return a Response object.
HTTP vals, unlike other vals, expose a public endpoint.

An HTTP val that works with the Web API takes a Request object as input and returns a Response object.

The most basic example can ignore the request and just return a response, even using a shorthand method like [Response.json, which is part of the web standard](https://developer.mozilla.org/en-US/docs/Web/API/Response/json_static).

Expand All @@ -29,4 +31,6 @@ We can grab query parameters using the web standard [URLSearchParams](https://de
You can also get the body of POST requests using the Request object,
for example if you had an endpoint that received JSON:

<Val url="https://www.val.town/embed/tmcw/jsonBodyParsing" />
<Val url="https://www.val.town/embed/tmcw/jsonBodyParsing" />

To obtain the HTTP endpoint for your HTTP val, use the "Copy HTTP endpoint" feature (located in the val's sidebar, or in its ... menu).

0 comments on commit c83eeaa

Please sign in to comment.