I am getting POST 400 bad request while using stripe - node.js

This is the error I'm getting on Console
POST http://localhost:3000/api/bookings/bookroom 400 (Bad Request) xhr.js:247
And this is on Network
{error: {type: "StripeInvalidRequestError", raw: {,…}, rawType: "invalid_request_error",…}}
I've tried like this. This is on client side
Client Side
Backend
server
I am not getting what is causing the error. Any insights?

Related

How we can show error message bad request 400 from Node.js express to react

I want retrive the message "email exist already" in react when we get a bad request from server
my console show undefined.

Browser not showing Internal Server Error HTML Page with status 500

I've two components in my application. A frontend which is built on Angular and backend built using express. I'm using the Nest.js framework in the backend.
I have an http-exception.filter.ts file which takes care of any thrown exception. So far, I've been handling Internal Server Error in the application this way.
if(exception.getStatus() === 500) {
response
.status(500)
.json({
status: '500',
code: 'INTERNAL_SERVER_ERROR',
message: 'Internal Server Error'
});
}
But, now an HTML page has been designed showing Internal Server Error message. All I need to do to render that page is to hit the URL /ui/internal-server-error. So, I tried to that using the code below.
response
.status(500)
.redirect('/ui/internal-server-error');
The page loads when a case of internal server error occurs, but the problem is I'm not getting 500 status when I'm reading the network logs in the browser. Instead, I'm getting 304 Not modified status.
Could anyone please point me in the right direction? I want to show the error page along with status code 500 and the UI page needs to come from Frontend only as I've no access over it.
When redirect is called, it sets the status, so the 500 is replaced.
From the express docs (relevant as NestJS uses Express by default):
Redirects to the URL derived from the specified path, with specified status, a positive integer that corresponds to an HTTP status code . If not specified, status defaults to “302 “Found”.
res.redirect('/foo/bar')
res.redirect('http://example.com')
res.redirect(301, 'http://example.com')
res.redirect('../login')
Add the desired status as an argument to redirect.

passport-twitter returns "Failed to load resource: the server responded with a status of 500 (Internal Server Error)"

I am stuck trying to solve the problem, but ended up with here. This is the erroneous code repo.
I got an error saying:
Failed to load resource: the server responded with a status of 500(Internal Server Error)`
and for such a code snippet, it always redirected to the failure URL (/routes/auth.js):
.get(passport.authenticate('twitter',
{
successRedirect: '/users/',
failureRedirect: '/error/'
})
);
Based on the current commit, I can successfully get the token from Twitter API. The callback URL is as such:
http://localhost:3000/auth/twitter/callback?oauth_token=(token)&oauth_verifier=(token)
Questions:
What went wrong?
If trying to debug the error, how could I construct the error-first callback (I did NOT even know where and how to output debug logs)?

how to resolve a HTTP 400 Bad Request error?

I have developed an Angular4 application that does HTTP requests to a nodeJS server application.
An URL works for http.get() but the same URL for http.put() or http.post() throws HTTP 400 Bad Request error.
How is this possible??
let temp=this._http.post("http://localhost:4200/medicine/edit/"
+String(updatedEmployee.id),updatedEmployee.id);
[angular code link]codeshare.io/5wlnLR
[express route code] codeshare.io/G8npdD

facebook messenger 404 file not found

I am trying to follow the example outlined here of creating a simple echo bot for Facebook Messenger https://developers.facebook.com/docs/messenger-platform/quickstart
I got most of it working, except for the sending message response part. I keep getting this error
Error sending message: { [Error: Not Found]
...
error:
{ [Error: cannot POST /v2.6/me/messages?access_token=<PAGE_TOKEN> (404)]
status: 404,
text: '404 File Not Found',
method: 'POST'
I am not sure why I would get a "404 File Not Found" error, and don't know what to do to fix it. Any advice or suggestion would be really appreciated!
I am not sure what the issue was, but I was able to upload a message try using request instead of superagent.

Resources