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

Post requests don't work. #74

Open
g0dzcsgo opened this issue Feb 26, 2024 · 1 comment
Open

Post requests don't work. #74

g0dzcsgo opened this issue Feb 26, 2024 · 1 comment

Comments

@g0dzcsgo
Copy link

It does send the request to my web-server yes, but it does not include any data.

Logging "req.query" yields a result of an empty object, and when logging "req.body" it's undefined.

I've tried both examples, the form data and the json body and none of them work.

For example, this is the example for JSON body

	try {
		http::Request request{ "http://0.0.0.0/get-confirmations" };
		const std::string body = "{ \"shared_secret\": \"" + account.shared_secret + "\", \"identity_secret\": \"" + account.identity_secret + "\" }";
		const auto response = request.send("POST", body, {
			{"Content-Type", "application/json"}
		});
		std::cout << std::string{ response.body.begin(), response.body.end() } << '\n'; // print the result
	} catch (const std::exception& e) {
		std::cerr << "Request failed, error: " << e.what() << '\n';
	}

This is how my web-server is setup atm, just a simple express api

app.post('/get-confirmations', (req, res) => {
    console.log("query", req.query);
    console.log("body", req.body);

    const { shared_secret, identity_secret } = req.query;

    if (!shared_secret || !identity_secret) {
        return res.status(400).send('Missing shared_secret or identity_secret');
    }

    return res.send('Hello world | Shared Secret: ' + shared_secret + ' | Identity Secret: ' + identity_secret);
});

What am I doing wrong?

@Skwrr
Copy link

Skwrr commented Aug 12, 2024

same issue here, didnt find a fix

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