-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parameters had a new line on the timeout that broke the regex for the…
… example gen
- Loading branch information
Showing
2 changed files
with
167 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
|
||
|
||
|
||
<!DOCTYPE html> | ||
<html class="default" lang="en"> | ||
|
||
<head> | ||
<meta charSet="utf-8" /> | ||
<meta http-equiv="x-ua-compatible" content="IE=edge" /> | ||
<title>Parameters Example</title> | ||
<meta name="description" content="Documentation for cwmsjs" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<link rel="stylesheet" href="../assets/style.css" /> | ||
<link rel="stylesheet" href="../assets/highlight.css" /> | ||
<script defer src="../assets/main.js"></script> | ||
<script async src="../assets/icons.js" id="tsd-icons-script"></script> | ||
<script async src="../assets/search.js" id="tsd-search-script"></script> | ||
<script async src="../assets/navigation.js" id="tsd-nav-script"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.26.0/themes/prism.css" id="light-theme" disabled> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.26.0/themes/prism-okaidia.css" id="dark-theme"> | ||
</head> | ||
|
||
<body> | ||
<script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"; document.body.style.display = "none"; setTimeout(() => app ? app.showPage() : document.body.style.removeProperty("display"), 500)</script> | ||
<script> | ||
const lightTheme = document.getElementById('light-theme'); | ||
const darkTheme = document.getElementById('dark-theme'); | ||
if (document.documentElement.dataset.theme == "light") { | ||
lightTheme.disabled = false; | ||
darkTheme.disabled = true; | ||
} else { | ||
lightTheme.disabled = true; | ||
darkTheme.disabled = false; | ||
} | ||
</script> | ||
<header class="tsd-page-toolbar"> | ||
<div class="tsd-toolbar-contents container"> | ||
<div class="table-cell" id="tsd-search" data-base=".."> | ||
<div class="field"><label for="tsd-search-field" | ||
class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" | ||
viewBox="0 0 16 16" fill="none"> | ||
<use href="../assets/icons.svg#icon-search"></use> | ||
</svg></label><input type="text" id="tsd-search-field" aria-label="Search" /></div> | ||
<div class="field"> | ||
<div id="tsd-toolbar-links"></div> | ||
</div> | ||
<ul class="results"> | ||
<li class="state loading">Preparing search index...</li> | ||
<li class="state failure">The search index is not available</li> | ||
</ul><a href="/cwms-data-api-client-javascript/" class="title">HOME - cwmsjs - v1.12.0</a> | ||
</div> | ||
</div> | ||
</header> | ||
<div class="container container-main"> | ||
<div class="col-content"> | ||
<div class="tsd-page-title"> | ||
<ul class="tsd-breadcrumb"> | ||
<li><a href="../modules.html">cwmsjs</a></li> | ||
<li><a href="/cwms-data-api-client-javascript/examples">Examples</a></li> | ||
<li><a href="/cwms-data-api-client-javascript/examples/Parameters.html">Parameters</a></li> | ||
</ul> | ||
<h1>Example: Parameters</h1> | ||
</div> | ||
<section class="tsd-panel tsd-comment"> | ||
<div class="tsd-comment tsd-typography"> | ||
<p>An example for calling the Parameters endpoint via CDA in JavaScript</p> | ||
<p><a href="https://cwms-data.usace.army.mil/cwms-data">Swagger UI</a> for Endpoints</p> | ||
</div> | ||
<div class="tsd-comment tsd-typography"></div> | ||
</section> | ||
<section class="tsd-panel tsd-hierarchy"> | ||
|
||
<h2>React + Vite Example</h2> | ||
<b>To Install:</b> | ||
<code class="language-shell">npm install cwmsjs --save</code><br> | ||
<p><em>Download browser bundle.js <a href="https://github.com/HydrologicEngineeringCenter/cwms-data-api-client-javascript/blob/main/src/dist/bundle.js">here</a></em></p> | ||
<pre> | ||
<code class="language-javascript">import { ParametersApi } from "cwmsjs"; | ||
|
||
|
||
const p_api = new ParametersApi() | ||
await p_api.getCwmsDataParametersRaw({ | ||
"office": "SWT" | ||
}) | ||
.then(r => r.raw.json()) | ||
.then(data => { | ||
console.log(data.parameters) | ||
console.log(data?.parameters) | ||
console.log(data?.parameters?.parameters) | ||
Object.entries(data?.parameters?.parameters).forEach(([key, value]) => { | ||
console.log(value?.["abstract-param"]) | ||
console.log(value?.["office"]) | ||
console.log(value?.["default-english-unit"]) | ||
console.log(value?.["default-si-unit"]) | ||
console.log(value?.["long-name"]) | ||
console.log(value?.["description"]) | ||
}); | ||
|
||
}).catch(async e => { | ||
if (e.response) { | ||
const error_msg = await e.response.json() | ||
e.message = `${e.response.url}\n${e.message}\n${JSON.stringify(error_msg, null, 2)}`; | ||
console.error(e); | ||
throw e; | ||
} else { | ||
throw e; | ||
} | ||
})</code> | ||
</pre> | ||
<h2>Bundle / Vanilla JS Example</h2> | ||
<b>To Install:</b><br> | ||
<p> | ||
<ol> | ||
<li>Run <br> | ||
<code class="language-shell">curl -O "https://raw.githubusercontent.com/HydrologicEngineeringCenter/cwms-data-api-client-javascript/main/src/dist/bundle.js"</code><br> | ||
to download bundle.js to your system</li> | ||
<li>Copy bundle.js to your web directory if not in that directory already</li> | ||
</o> | ||
</p> | ||
<pre> | ||
<code class="language-html"><!-- Include the bundle.js file --> | ||
<script src="./bundle.js"></script> | ||
<!-- Call the cwmsjs after the bundle has loaded --> | ||
<script type="module"> | ||
const p_api = new cwmsjs.ParametersApi() | ||
await p_api.getCwmsDataParametersRaw({ | ||
"office": "SWT" | ||
}) | ||
.then(r => r.raw.json()) | ||
.then(data => { | ||
console.log(data.parameters) | ||
console.log(data?.parameters) | ||
console.log(data?.parameters?.parameters) | ||
Object.entries(data?.parameters?.parameters).forEach(([key, value]) => { | ||
console.log(value?.["abstract-param"]) | ||
console.log(value?.["office"]) | ||
console.log(value?.["default-english-unit"]) | ||
console.log(value?.["default-si-unit"]) | ||
console.log(value?.["long-name"]) | ||
console.log(value?.["description"]) | ||
}); | ||
|
||
}).catch(async e => { | ||
if (e.response) { | ||
const error_msg = await e.response.json() | ||
e.message = `${e.response.url}\n${e.message}\n${JSON.stringify(error_msg, null, 2)}`; | ||
console.error(e); | ||
throw e; | ||
} else { | ||
throw e; | ||
} | ||
}) | ||
</script></code> | ||
</pre> | ||
</section> | ||
</div> | ||
</div> | ||
<footer> | ||
<p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p> | ||
</footer> | ||
<div class="overlay"></div> | ||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.26.0/prism.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters