Put in axios cannot get data

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:
     

clipboard.png

Mar.25,2021

first determine whether the backend supports the put method.
check with the backend. Can it be done if it is post? Take a look at the joint adjustment

before changing it to put.
Menu