Search code examples
curlocamljs-of-ocaml

Js_of_ocaml : missing primitive when calling ocurl and str


I'm using the packages curl in order to make Http request (and the package str to use regex). I'm compiling the files in my project, no probleme and when I compile the file.byte with js_of_ocaml, I have these errors :

js_of_ocaml --disable genprim foo.byte

Missing primitives:
  helper_curl_easy_cleanup
  helper_curl_easy_duphandle
  helper_curl_easy_getinfo
  helper_curl_easy_init
  helper_curl_easy_perform
  helper_curl_easy_setopt
  helper_curl_global_init
  re_search_forward
  re_string_match

And when I included the generated js file, I have this error in the web console : Uncaught ReferenceError: helper_curl_global_init is not defined

I know that there is missing primitives and it's cause the error that I have but there is a solution to fix that ?


Solution

  • To do http requests in js_of_ocaml, you will need to use that module: http://ocsigen.org/js_of_ocaml/2.5/api/XmlHttpRequest