Отправка запроса с использованием ax ios и C# HTTPListener - PullRequest
0 голосов
/ 02 апреля 2020

У меня есть этот метод в моем приложении для реагирования

export async function createUser(state) {
  const url = "http://localhost:8080";

  console.log("Sending request");
  const response = await axios.post(url, {
    t: "create",
    email: state.email,
    password: state.password,
    username: state.username,
    phone: state.phone,
    morada: state.morada,
    postCode: state.postCode
  });
  return String(response.data);
}

И он работает в Visual Studio

private void Listen() {
        listener = new HttpListener();
        listener.Prefixes.Add("http://localhost:" + port.ToString() + "/");
        listener.Start();

        while (true) {
            try {
                HttpListenerContext context = listener.GetContext();
                Process(context);
            }
            catch (Exception ex) {
                Console.WriteLine(ex.ToString());
            }
        }
    }

    private void Process(HttpListenerContext context) {

        var data_text = new StreamReader(context.Request.InputStream,
    context.Request.ContentEncoding).ReadToEnd();

        Console.WriteLine(data_text);
}

У меня он работает нормально для запросов GET. Теперь я хочу сделать POST, и я получаю только пустое место. Из того, что я мог найти в inte rnet, это то, как вы получаете данные из запроса POST, но я просто ничего не получаю. Любая помощь будет оценена

...