score:-3

axios for post request with json as its body:

  static async postservice(path, data = {}) {
    const requesturl = httprequest._getrequesturl(path);

    try {
      const ret = await axios.post(requesturl, json.stringify(data));
      console.log('request result ', ret);
    } catch (error) {
      console.error(`request error: ${error.message}`);
    }
  }

score:6

you don't need to stringify your payload. axios will do it for you when it it send a request.

const dt = { data: { value: "gdfg1df2g2121dgfdg" }};
const request = axios.post(url, dt);

score:15

by default axios uses json for posting data so you don't need to stringify your data. the problem could be that you're doing that. could you try doing the post without it and check if it works? also you don't need the curly braces to wrap your data unless that's the format of the object in your server. otherwise could you give me information about how the body of the request looks like so i have more context? you can check that in chrome dev tools using the network tab


Related Query

More Query from same tag