neandertech / smithy4s-fetch Goto Github PK
View Code? Open in Web Editor NEWSmithy4s client directly using Fetch APIs, without bringing http4s/cats, to dramatically reduce bundle size
Smithy4s client directly using Fetch APIs, without bringing http4s/cats, to dramatically reduce bundle size
To reproduce:
//> using dep "tech.neander::smithy4s-deriving::0.0.2"
//> using dep tech.neander::smithy4s-fetch::0.0.3
//> using platform scala-js
//> using scala 3.4.2
//> using option -Wunused:all
import smithy4s.*
import scala.annotation.experimental
import scala.scalajs.js.Promise
import deriving.given
import deriving.*
import aliases.*
import smithy4s_fetch.SimpleRestJsonFetchClient
@experimental
trait HttpbinService derives API:
@readonly
@httpGet("/get")
def get(): Promise[Document]
@main @experimental
def helloWorld =
val service: HttpbinService =
SimpleRestJsonFetchClient(
API.service[HttpbinService],
"https://httpbin.org/api",
).make.unliftService
service.get().`then`(v => println(v))
<!DOCTYPE html>
<html>
<head>
<script src="./helloWorld.js" type="text/javascript"></script>
</head>
</html>
Open the HTML file, see network tab in the browser, look for the request path.
https://httpbin.org/api/get
https://httpbin.org//api/get
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.