404-Service Examples

Reason API Usage Examples

JavaScript (Fetch)
Python (Requests)
HTML (Embed)
Raw
Output
fetch('https://404-service.com/reason')
  .then(res => res.json())
  .then(data => console.log(data.reason));
import requests

response = requests.get('https://404-service.com/reason')
if response.status_code == 404:
    print(response.json()['reason'])
else:
    print("Request failed")
<!-- Simple Example -->
<p id="reason">Loading...</p>

<script>
  fetch('https://404-service.com/reason')
    .then(r => r.json())
    .then(data => {
      document.getElementById('reason').textContent = data.reason;
    })
    .catch(() => {
      document.getElementById('reason').textContent = "Connection failed";
    });
</script>
Console
▶ fetch('https://404-service.com/reason')
Promise { <pending> }
→ resolved ✓
...
Terminal
$ python snippet.py
...
Rendered DOM

Loading...

← Back to Home