Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to receive payload #10

Open
rohinrohin opened this issue Jul 17, 2017 · 1 comment
Open

Unable to receive payload #10

rohinrohin opened this issue Jul 17, 2017 · 1 comment

Comments

@rohinrohin
Copy link

rohinrohin commented Jul 17, 2017

const beaverLogger = require('beaver-logger/server');
const express = require('express');
// const bodyParser = require('body-parser');

const app = express();

// app.use(bodyParser.raw);
// app.use(bodyParser.json());

app.use(beaverLogger.expressEndpoint({
    // URI to recieve logs at
    uri: '/api/log',
    // Enable cross-origin requests to your logging endpoint
    enableCors: true
}));

This is my server code. The client init code is very similar to the demo code however I am passing the payload like so

$logger.error('hello_world', {
  error: "somthing happened"
});
$logger.error('hello_world');
$logger.flush();

Whenever I try to log I only get an empty out with

[meta]

[track]
// or sometimes
[meta]
    state: undefined
[track]

On further debugging I found that the request req.query object is always empty. I am also unsure as to why you are checking for req.query in your handleRequest method.

When I build my own endpoint for this logger I am able to get the data successfully like so:

{"events":[{"level":"error","event":"hello_world","payload":{"error":"somthing happened","timestamp":1500277459545,"windowID":"827a850fd2","pageID":"8d9532cb6b","client_elapsed":439078,"req_elapsed":440637}},{"level":"error","event":"hello_world","payload":{"timestamp":1500277459546,"windowID":"827a850fd2","pageID":"8d9532cb6b","client_elapsed":439079,"req_elapsed":440638}}],"meta":{"state":"ui_init"},"tracking":[]}

Since there is limited documentation on the same, I am unable to figure out why this is happening.

Note:
HTML file is locally served from the system (using file:// ....)

@tamsingreen
Copy link

I was having the same issue til I realised you need to have body-parser in place. If you uncomment those three lines from your server code it should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants