function in js, two parameters, id and data
import axios from "axios";
import qs from" qs";
export let updateBook= (id,data) = > {
return axios.put ( / book?id=$ {id}
, qs.stringify (data));
};
after sending the request, no data was obtained and an error was reported
case "PUT":
if(id){
let str = "";
req.on("data",chunk=>{
str+=chunk;
console.log(str);
});
console.log(str);
req.on("end",()=>{
let book = JSON.parse(str);
read(function (books) {
books = books.map(item=>{
if(item.bookId === id){
return book
}
return item;
});
write(books,function () {
res.end(JSON.stringify(book));
})
});
})
}
break;
console: