`Why doesn't patch work in axios?
A
A
Alexander Ivanov2019-02-28 11:23:27
JavaScript
Alexander Ivanov, 2019-02-28 11:23:27

Why doesn't patch work in axios?

// this.$http.delete(
            //     `//${this.$store.state.apiPath}/company?id=43`,
            this.$http.patch(
                `//${this.$store.state.apiPath}/company?id=1&c_limit=1900`
                // { headers: { Authorization: `Bearer ${localStorage.getItem('access_token')}` } }
            ).then(({ data }:any) => {
                console.log(data)
            })
            .catch((e:any) => {
                console.log(e);
            });

If I uncomment delete and comment out patch it will work.
Also put, post, get work, but something is wrong with patch.
For some reason, he leaves Authorization in the request body and does not throw it in the headers.
5c7799fa33e77855484214.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ivanov, 2019-02-28
@cimonlebedev

First parameters then header for post put and patch

this.$http.patch(
                `//${this.$store.state.apiPath}/company`,
                { params: { id: 1, c: 1900 } },
                { headers: { Authorization: `Bearer ${localStorage.getItem('access_token')}`} }
            ).then(({ data }:any) => {
                console.log(data)
            })
            .catch((e:any) => {
                console.log(e);
            });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question