add example for axios custom instance
This commit is contained in:
parent
114c46be60
commit
bcaff40fd7
|
@ -0,0 +1,9 @@
|
||||||
|
import axios from "axios"
|
||||||
|
|
||||||
|
const axiosAuth = axios.create({
|
||||||
|
baseURL: "https://axios-test-44b62-default-rtdb.europe-west1.firebasedatabase.app"
|
||||||
|
})
|
||||||
|
|
||||||
|
axiosAuth.defaults.headers.common['SOMETHING'] = "something"
|
||||||
|
|
||||||
|
export default axiosAuth
|
|
@ -69,7 +69,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios';
|
import axios from '../../axios-auth';
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
@ -104,7 +104,7 @@ import axios from 'axios';
|
||||||
terms: this.terms
|
terms: this.terms
|
||||||
}
|
}
|
||||||
console.log(formData)
|
console.log(formData)
|
||||||
axios.post("https://axios-test-44b62-default-rtdb.europe-west1.firebasedatabase.app/users.json", formData)
|
axios.post("/users.json", formData)
|
||||||
.then(response => console.log(response))
|
.then(response => console.log(response))
|
||||||
.catch(error => console.log(error));
|
.catch(error => console.log(error));
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue