Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Feb 9, 2021
1 parent 428c56e commit e7972f5
Showing 1 changed file with 49 additions and 50 deletions.
99 changes: 49 additions & 50 deletions MyApp/wwwroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,49 @@
</style>
</head>
<body>

<h2><a href="/json/metadata?op=Hello">Hello</a> API</h2>
<input type="text" id="txtName" onkeyup="callHello(this.value)">
<div id="result"></div>

<script>
var exports = { __esModule:true }, module = { exports:exports }
function require(name) { return exports[name] || window[name] }
</script>
<script src="/js/servicestack-client.js"></script>
<script src="/dtos.js"></script>
<script>
Object.assign(window, exports); //import

var client = new JsonServiceClient();
function callHello(val) {
client.get(new Hello({ name: val }))
.then(function(r) {
document.getElementById('result').innerHTML = r.result;
});
}

callHello(document.querySelector('#txtName').value = 'World')
</script>

<div style="font-size:20px;line-height:26px">
<h3>Using JsonServiceClient in Web Pages</h3>

<p>
Update your App's
<a href="https://docs.servicestack.net/typescript-add-servicestack-reference">TypeScript DTOs</a> and
compile to JS
(requires <a href="https://nodejs.org/en/">Node.js</a> + <a href="https://www.typescriptlang.org/download">TypeScript</a>):
</p>

<pre>$ npm run dtos</pre>

<h3>Including @servicestack/client &amp; Typed DTOs</h3>

<p>
Create a basic UMD loader then include the UMD <b>@servicestack/client</b> library and <b>dtos.js</b>:
</p>

<pre>&lt;script&gt;

<h2><a href="/json/metadata?op=Hello">Hello</a> API</h2>
<input type="text" id="txtName" onkeyup="callHello(this.value)">
<div id="result"></div>

<script>
var exports = { __esModule:true }, module = { exports:exports }
function require(name) { return exports[name] || window[name] }
</script>
<script src="/js/servicestack-client.js"></script>
<script src="/dtos.js"></script>
<script>
Object.assign(window, exports); //import

var client = new JsonServiceClient();
function callHello(val) {
client.get(new Hello({ name: val }))
.then(function(r) {
document.getElementById('result').innerHTML = r.result;
});
}

callHello(document.querySelector('#txtName').value = 'World')
</script>

<div style="font-size:20px;line-height:26px">
<h3>Using JsonServiceClient in Web Pages</h3>

<p>
Update your App's
<a href="https://docs.servicestack.net/typescript-add-servicestack-reference">TypeScript DTOs</a> and
compile to JS (requires <a href="https://www.typescriptlang.org/download">TypeScript</a>):
</p>

<pre>$ x scripts dtos</pre>

<h3>Including @servicestack/client &amp; Typed DTOs</h3>

<p>
Create a basic UMD loader then include the UMD <b>@servicestack/client</b> library and <b>dtos.js</b>:
</p>

<pre>&lt;script&gt;
var exports = { __esModule:true }, module = { exports:exports }
function require(name) { return exports[name] || window[name] }
&lt;/script&gt;
Expand All @@ -65,7 +64,7 @@ <h3>Including @servicestack/client &amp; Typed DTOs</h3>
We can then import the library and DTO types in the global namespace to use them directly:
</p>

<pre>Object.assign(window, exports) //import
<pre>Object.assign(window, exports) //import

var client = new JsonServiceClient()
client.get(new Hello({ name: name }))
Expand All @@ -82,11 +81,11 @@ <h3>Using @servicestack/client in npm projects</h3>
let response = await client.get(new Hello({ name }))
</pre>

<p>
Typed DTOs generated using
<a href="https://docs.servicestack.net/typescript-add-servicestack-reference">TypeScript Add ServiceStack Reference</a>
</p>
</div>
<p>
Typed DTOs generated using
<a href="https://docs.servicestack.net/typescript-add-servicestack-reference">TypeScript Add ServiceStack Reference</a>
</p>
</div>

</body>
</html>

0 comments on commit e7972f5

Please sign in to comment.