Hi all
I know, it exists an axios bs version but I will try to implement by myself.
I have the following code:
[@bs.deriving abstract]
type data = {
coinSymbol: string,
amount: int,
};
[@bs.deriving abstract]
type config = {
headers: Js.Dict.t(string)
};
[@bs.module "axios"]
external post :
(~url: string, ~data: data, ~config: config) => Js.Promise.t('a) =
"";
let d = data(~coinSymbol="BTC", ~amount=22);
let dict = Js.Dict.empty();
Js.Dict.set(dict, "Content-Type", "application/json");
let c = config(~headers=dict);
let reqData = post(~url="http://localhost:3000/test", ~data=d, ~config= c);
and the compiler complains:
import * as Axios from "axios";
^
SyntaxError: Unexpected token *
at new Script (vm.js:74:7)
at createScript (vm.js:246:10)
at Object.runInThisContext (vm.js:298:10)
at Module._compile (internal/modules/cjs/loader.js:670:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
package.json file:
{
"name": "interoperate",
"version": "0.1.0",
"scripts": {
"build": "bsb -make-world",
"start": "bsb -make-world -w",
"clean": "bsb -clean-world"
},
"keywords": [
"BuckleScript"
],
"author": "",
"license": "MIT",
"devDependencies": {
"bs-platform": "^3.1.5"
},
"dependencies": {
"axios": "^0.18.0"
}
}
Thanks