L
L
luckyjenro02022-01-13 23:29:49
PHP
luckyjenro0, 2022-01-13 23:29:49

Why is POST not being sent via Vue Resource?

get_data() {
      this.$http
        .post("/call.php", {
          params: { foo: "bar" },
          headers: { "Content-Type": "application/json" },
        })
        .then(
          (response) => {
            // success callback
          },
          (response) => {
            // error callback
          }
        );
    },


Writes that the page is not found, although this cannot be.
61e09c9bd415b174464585.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2022-01-14
@luckyjenro0

Man, if you're using vue-cli, random files you just drop somewhere won't magically appear in the built-in server. The public folder is intended for publicly accessible files.
However, the built-in vue-cli server cannot and should not be able to execute php, this is a completely different language and technology.
For development, you need to set up a separate php server on a separate port and forward similar requests to it through the vue devserver proxy.
To sell - you need to set up a prod server to your liking.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question