Put request with simple string as request body

前端 未结 8 721
谎友^
谎友^ 2020-12-24 13:52

When I execute the following code from my browser the server gives me 400 and complains that the request body is missing. Anybody got a clue about how I can pass a simple st

8条回答
  •  被撕碎了的回忆
    2020-12-24 14:36

    this worked for me.

    let content = 'Hello world';
    
    static apicall(content) {
    return axios({
      url: `url`,
      method: "put",
      data: content
     });
    }
    
    apicall()
    .then((response) => {
       console.log("success",response.data)
    }
    .error( () => console.log('error'));
    

提交回复
热议问题