Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
<h1>Cross fetch</h1>
<script type="text/javascript" src="../dist/fido.js"></script>
<script type="text/javascript">
requestGet('https://cors-anywhere.herokuapp.com/').then(res => console.log(res)).catch(err => console.error(err));
fetch('https://cors-anywhere.herokuapp.com/').then(res => console.log(res)).catch(err => console.error(err));
getGeoService();
</script>
</body>
</html>
5 changes: 2 additions & 3 deletions src/Fido.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

export * from './Fido_sources.gen';
export { requestGet } from './web/FidoJs.gen';
export { getGeoService } from './web/FidoJs.gen';

// export {
// } from './Fido_types.gen';
export * from './Fido_types.gen';
4 changes: 2 additions & 2 deletions src/Fido_sources.re
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// open Fido_types;
open Fido_types;

[@genType]
let requestGet = Http.Client.fetch;
let getGeoService = Http.Client.get("https://geo.6play.fr/v1/geoInfo/");
12 changes: 11 additions & 1 deletion src/Fido_types.re
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@

[@genType]
type geoServiceType = {
timezone: string,
offset: int,
isp: string,
country_code: string,
asn: string,
ip: string,
is_anonymous: bool,
areas: list(int),
};
1 change: 1 addition & 0 deletions src/dune/Fido.re
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
module Types = Fido_types;
/* include Fido_sources; */
10 changes: 6 additions & 4 deletions src/include/http_js/Client_js.re
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
let fetch = (~path: string) =>
let get = (path: string, ()) =>
Js.Promise.(
Fetch.fetch(path)
|> then_(Fetch.Response.text)
|> then_(text => print_endline(text) |> resolve)
Fetch.fetchWithInit(path, Fetch.RequestInit.make(~mode=CORS, ()))
|> then_(Fetch.Response.json)
|> then_(json => Js.Json.decodeObject(json) |> resolve)
|> then_(opt => Belt.Option.getExn(opt) |> resolve)
|> then_(items => Js.log(items) |> resolve)
);
2 changes: 1 addition & 1 deletion src/include/http_native/Client_native.re
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let fetch = (~path: string) =>
let get = (path: string, ()) =>
Fetch.(
fetch(path)
|> Lwt.map(
Expand Down
4 changes: 2 additions & 2 deletions src/web/FidoJs.re
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// open Fido_types;
open Fido_types;

[@genType]
let requestGet = Http.Client.fetch;
let getGeoService = Http.Client.get("https://geo.6play.fr/v1/geoInfo/");