encode/parse json
This commit is contained in:
parent
c7a8f2e5a1
commit
ec3ece5bde
|
@ -6,7 +6,7 @@ import { useState,useEffect } from "react";
|
||||||
import { forIn } from "lodash";
|
import { forIn } from "lodash";
|
||||||
|
|
||||||
export async function action({request,params}){
|
export async function action({request,params}){
|
||||||
const data = await request.formData()
|
const data = await request.json()
|
||||||
console.dir(data)
|
console.dir(data)
|
||||||
data.id=params.storyId
|
data.id=params.storyId
|
||||||
await requestEdit(data,'story')
|
await requestEdit(data,'story')
|
||||||
|
@ -49,12 +49,21 @@ export default function EditStory(){
|
||||||
const handleSave = (event) =>{
|
const handleSave = (event) =>{
|
||||||
submit(data,{
|
submit(data,{
|
||||||
method:"post",
|
method:"post",
|
||||||
action: `/story/${storyId}/edit`
|
action: `/story/${storyId}/edit`,
|
||||||
|
encType: "application/json"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
console.dir(data)
|
console.dir(data)
|
||||||
},[data])
|
},[data])
|
||||||
|
useEffect(()=>{
|
||||||
|
setData(prev=>{
|
||||||
|
return {
|
||||||
|
...prev,
|
||||||
|
genres:storyData.genres
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},[storyData])
|
||||||
return(
|
return(
|
||||||
<div id="page-container">
|
<div id="page-container">
|
||||||
<PageHeader super={`Story #${storyData.id}`} heading="EDIT" url="/story" id={storyId}/>
|
<PageHeader super={`Story #${storyData.id}`} heading="EDIT" url="/story" id={storyId}/>
|
||||||
|
@ -85,7 +94,7 @@ export default function EditStory(){
|
||||||
name="genres"
|
name="genres"
|
||||||
options={genres}
|
options={genres}
|
||||||
onChange={handleToggle}
|
onChange={handleToggle}
|
||||||
values={genres}
|
values={data.genres}
|
||||||
legend="Genres:"
|
legend="Genres:"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
Loading…
Reference in New Issue