my endpoint isn't receiving the data parameters from a post
See original GitHub issueI’ve got an existing form endpoint that works when submitting via a standard ajax/jQuery call, but when I use Axios to post to it, the endpoint is not receiving any of the data from the data attribute.
I am posting to a file on the same server, not a CORS.
Anything I put in the URL reaches the endpoint as expected.
export function selectSubscription(data){
const url = '/remoting/credits.cfc';
let params = {};
const requiredFields = [
'PRODUCT_PACKAGE_ID',
'REPLENISH_PACKAGE_ID',
'REPLENISH_THRESHOLD',
'SCHOOL_SUBSCRIPTION_ID'
];
let validFormData = jsonHasFields(data, requiredFields);
if (!validFormData.success) {
return {
type: 'INVALID_FORM',
keys: validFormData.keys
}
}
params.method = 'selectSubscription';
for (let i=0; i < requiredFields.length; i++) {
let key = requiredFields[i];
params[key] = data[key];
}
//const request = axios.post(url, params);
const request = axios({
method: 'post',
url: url,
data: params
})
//$.post(url, params, function(result){debugger;});
return {
type: 'SELECT_SUBSCRIPTION',
payload: request
}
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (6 by maintainers)
Top Results From Across the Web
POST method endpoint not being hit but GET ... - Stack Overflow
I just create a test project. I added a controller with two methods called [HttpGet] void CreateOne() and [HttpPost] void CreateTwo() (you can't ......
Read more >Step 3: Parameters (API reference tutorial) | Documenting APIs
Parameters are options you can pass with the endpoint (such as specifying the response format or the amount returned) to influence the ...
Read more >Building requests | Postman Learning Center
You can send requests in Postman to connect to APIs you are working with. Your requests can retrieve, add, delete, and update data....
Read more >Pass API Gateway REST API parameters to a Lambda ... - AWS
I need my Amazon API Gateway REST API to pass query string parameters to a backend AWS Lambda function and an HTTP endpoint....
Read more >Troubleshooting Error Messages
This type of error message occurs when the request URL or a request body parameter contains invalid or improperly formatted data. Below you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It looks like your endpoint expects data to be in x-www-form-urlencoded format while axios sends data in JSON format by default. axios does not support x-www-form-urlencoded format at the moment (please see #97), but it will soon. Meanwhile, you can do the following:
Hope this helps!
axios v0.12.0 supports x-www-form-urlencoded. Please see this comment.