How to use 'fetch status code' in JavaScript

Every line of 'fetch status code' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
49async function fetchStatus(url: string) {
50 const response = await fetch(url);
51
52 if (response.status !== 200) {
53 throw new Error(response.statusText);
54 }
55
56 const result = await response.json();
57
58 if (result.error) {
59 throw new Error(result.error);
60 }
61
62 return {
63 status: result.count === 1 && result.build[0].status === 'SUCCESS' ? 'passing' : 'failing',
64 build: result.build[0].number,
65 };
66}

Related snippets