Skip to content

stefanduberg/bs-xmlhttprequest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bs-xmlhttprequest

XMLHttpRequest bindings for BuckleScript.

Install

yarn:

yarn add bs-xmlhttprequest

npm:

npm install bs-xmlhttprequest

Add bs-xmlhttprequest to bs-dependencies in bsconfig.json.

Example

let xhr = XmlHttpRequest.make();

XmlHttpRequest.open_(xhr, ~method="GET", ~url="https://api.github.com/", ~async=true, ());

XmlHttpRequest.setRequestHeader(xhr, "user-agent", "bs-xmlhttprequest");

XmlHttpRequest.addEventListener(
  xhr,
  `load(
    _event => {
      let body = XmlHttpRequest.responseText(xhr);
      let status = XmlHttpRequest.status(xhr);
      Js.log2(status, body);
    },
  ),
);

XmlHttpRequest.send(xhr);

About

XMLHttpRequest bindings for BuckleScript

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages