diff --git a/examples/fetch/index.js b/examples/fetch/index.js index c2d3d2ae..dbad2808 100644 --- a/examples/fetch/index.js +++ b/examples/fetch/index.js @@ -2,7 +2,7 @@ const rust = import('./pkg'); rust .then(m => { - return m.run().then((data) => { + return m.run("rustwasm/wasm-bindgen").then((data) => { console.log(data); console.log("The latest commit to the wasm-bindgen %s branch is:", data.name); diff --git a/examples/fetch/src/lib.rs b/examples/fetch/src/lib.rs index 3ef43ae7..d1dd7524 100644 --- a/examples/fetch/src/lib.rs +++ b/examples/fetch/src/lib.rs @@ -33,13 +33,15 @@ pub struct Signature { } #[wasm_bindgen] -pub async fn run() -> Result { +pub async fn run(repo: String) -> Result { let mut opts = RequestInit::new(); opts.method("GET"); opts.mode(RequestMode::Cors); + let url = format!("https://api.github.com/repos/{}/branches/master", repo); + let request = Request::new_with_str_and_init( - "https://api.github.com/repos/rustwasm/wasm-bindgen/branches/master", + &url, &opts, )?;