facebook messenger 404 file not found - node.js

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.

Related

I am getting POST 400 bad request while using stripe

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?

VueJS axios.get returns Error: Request failed with status code 404

I've been debugging this code for a while, without much luck:
async getEvents() {
try {
let response = await axios.get("http://localhost:8000/events/");
console.log(response);
return response.data;
} catch (error) {
console.error(error);
}
}
The complete code sample is from: https://auth0.com/blog/how-to-make-secure-http-requests-with-vue-and-express/
I receive an error when visiting the site that calls the API endpoint:
Error: Request failed with status code 404
at createAxiosError (utils.js?c786:148)
at Object.settle (utils.js?c786:127)
at handleRequest (handle_request.js?da0c:126)
at eval (index.js?94db:26)
at new Promise (<anonymous>)
at MockAdapter.eval (index.js?94db:25)
at dispatchRequest (dispatchRequest.js?5270:52)
If I just copy the url (http://localhost:8000/events/) in the browser I receive the correct data. I have tried with and without trailing slashes.
Am I misunderstanding the error message, and should I look elsewhere?
In computer network communications, the error 404 indicates that the browser was able to communicate with a given server, but the server could not find what was requested, in other words, the request url did not exist. So you want to double-check that.
Solution: Go to the network tab, click on the error request, inside the Headers, you can see the actual request url which has been sent to the server.
A 404 usually indicates that the resources was not found. Have you added any previous setup to your Axios instances? like the baseURL?
Most of the time the BaseURL is set to on an Axios instance that can cause confusion and issues.
I Had the same issue, then just added in my catch(vuex) error.response

Express Flash message doesn't work with Axios but works in Postman. Why is that?

I couldn't figure out why my flash message wasn't available when testing a bad password login. Finally I figured it out; flash doesn't work with Axios.
Why is it that flash-connect doesn't work with Axios but it works with Postman? I'm a noob with sessions, so I think it may have something to do with sessions.
I used Node.js, Express.js, Passport.js
Here is the gist.
How to recreate using the gist:
Save each file in a project folder
npm install
npm start
You'll see axios log to the console: "Error from Flash Message: undefined". The flash message is missing.
If you use Postman and post to http://localhost:3300/login with the body { "email":"test#test.com", "password": "paskword" } you get the correct flash message: Error from Flash Message: invalid password.

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)?

firebase Http function error

I have written a Firebase Http function.
When successful it returns status 200 with some data.
When it errors I want the client (which is using axios.post) to use a standard error handler which means showing the error.message property.
If I send an error code back with data - yes, I can access that data/message etc in error.response.data, but that isn't a pattern I can use for all errors - some errors might occur that don't give a response or data property.
So if I just want to access error.message at the client I need to be able to set that message but at the moment if I use for example:-
res.status(520).send('My custom error message')
I get:
Request failed with status 520
in the error.message, then I have to go to the error.response.data to get the actual message I want to display.
How could I do this so that I just use error.message regardless? I have tried using
res.status(x).send({error:customerror})
also tried
res.statusText = customerror
As you can see on Axios documentation, you have to use the error.response to get info from your custom message. You wouldn't be able to set the value on error.message on Axios.
If you really need to use error.message, you have to make a custom function to change it on cliente.

Resources