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
Source: stackoverflow.com
Related Query
- axios post request with json data
- Send JSON data as multipart/form-data using axios POST Request
- POST request with Axios not sending data to my server
- Accessing data inside my API with axios post request
- update the state of my component with the response data after Post request with axios
- ReactJS axios POST request send all options as a single JSON key with empty value
- How to POST a JSON with data provided by user with REACTJS and Axios
- How to perform a post request with axios on React and pass your data as FormData?
- axios post request to send form data
- react native post form data with object and file in it using axios
- Making redirects after an axios post request with express
- Catch return json from POST with Axios when error 400 (Bad Request) occurs
- How to have config parameter in axios post request with headers required
- axios post data as form data instead of as JSON in payload
- Can't get headers from Http POST request with Axios
- Cannot make POST request with JSON from react/axios to restify server
- React - Axios POST form data with files and strings
- how do I make a post and get request with ReactJS, Axios and Mailchimp?
- How to make a POST request with json content type with Semantic UI API
- HTTP POST request with JSON payload from react app returns net::ERR_SSL_PROTOCOL_ERROR(chrome)
- Axios post request with typescript issue
- Rendering json data with axios
- How to POST request using axios with React Hooks?
- Post request with axios and redux-thunk in a redux-form
- How to get axios post data request on nodeJs
- Reading JSON data with axios and React
- axios post request error with 422 (Unprocessable Entity) from react
- How to send data as string and not json on axios post
- Sending POST request with body in axios
- Request failed with status code 500 error. When making form post of multiForm data in React
More Query from same tag
- Using Redux with models
- In React how to CSS reference variables in separate files
- Redux: Can't figure out why ownProps gets out of sync with state
- Conditional rendering not working with styled-components
- Filtering Complex JSON Data
- Material-UI Error: Object is not a function within makeStyles?
- How to you test a redux dumb component that renders smart components?
- I want to disable end date picker before choosing start date picker in react js
- How to access state from callback function
- I get Parsing error: ':' expected.eslint in this code but can't see where
- How to dynamically add the valueOptions of a singleSelect column in Material-UI's DataGrid?
- React Component does not re-render on context change with useContext
- Having trouble increasing item quantity when multiple of the same item are added to very simple cart element
- Dispatching clear state action in redux
- Giving a default value to redux-form Field in a FieldArray when adding new Fields
- React JS Context API - Window Scroll Events
- Formik initial values from redux store
- i18next warn or lint on missing key for a language (not the fallbackLng)
- Use react routes depending by condition
- how to make a test case to check the value of counter will not be less than zero even if decrement button is pressed
- Separate debounce for each React component instance
- React couldn't read the state
- Error: EPERM : Operation not permitted,mkdir
- react hooks setInterval,Why can it be modified for the first time
- How to compare object properties between different objects in different arrays
- Export and Import Passport.JS Issues
- How do I do a set timer within each react component?
- Why my debounce functionality is not working in a React app with hooks?
- interface is not assignable to type Record<string, unknown>
- React router - history.push to a specific section of page