v0.10-frontend-compiles2
This commit is contained in:
@@ -282,7 +282,7 @@ return Json(res);
|
||||
|
||||
async fn create_book(
|
||||
Extension(ref conn): Extension<DatabaseConnection>,
|
||||
doc_sent : Form<BookUI>,
|
||||
Json(doc_sent): Json<BookUI>,
|
||||
) -> impl IntoResponse {
|
||||
println!("Creating book");
|
||||
let book: book::Model = book::Model{
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user