v0.10-frontend-compiles2

This commit is contained in:
2022-10-31 00:43:14 +05:30
parent bc58e586f7
commit cae044c830
2 changed files with 4 additions and 4 deletions

View File

@@ -2,6 +2,7 @@ use log::info;
//use log::Level;
use reqwasm::http::Request;
use serde::{Deserialize, Serialize};
use serde_json;
use sycamore::futures::spawn_local;
use sycamore::prelude::*;
//use sycamore::suspense::Suspense;
@@ -67,7 +68,7 @@ async fn fetch_books(search: String) -> Result<Vec<BookUI>, reqwasm::Error> {
async fn add_book(record: BookUI) -> Result<reqwasm::http::Response, reqwasm::Error> {
let url = format!("http://localhost:8081/api/create");
let resp = Request::post(&url).body(serde_wasm_bindgen::to_value(&record).unwrap()).header("content-type","application/x-www-form-urlencoded").send().await?;
let resp = Request::post(&url).body(serde_wasm_bindgen::to_value(&serde_json::to_string(&record).unwrap()).unwrap()).header("content-type","application/json").send().await?;
Ok(resp)
}
@@ -101,7 +102,6 @@ pub fn Header<G: Html>(cx: Scope) -> View<G> {
if !task.is_empty() {
app_state.search.set(task);
app_state.openlibrary.set(true);
println!("Fetching search\n");
info!("Fetching search\n");
value.set("".to_string());
input_ref
@@ -121,7 +121,7 @@ pub fn Header<G: Html>(cx: Scope) -> View<G> {
h1 { "Search OpenLibrary" }
input(ref=input_ref,
class="new-todo",
placeholder="What needs to be done?",
placeholder="Search openlibrary",
bind:value=value,
on:keyup=handle_submit,
)