NestJS returning the result of an HTTP request
This issue comes from the axios library. In order to fix that, you have to pull out the data property: return this.httpService.post(…) .pipe( map(response => response.data), );
This issue comes from the axios library. In order to fix that, you have to pull out the data property: return this.httpService.post(…) .pipe( map(response => response.data), );
As the error is saying: The “data” option should be a function In the component, the data must be a function, you need to modify the data block to be a function which will return the data structure to be used in DOM in a reactive way: Vue.component(‘symbols-table’, { template: ‘<h1>Hello World</h1>’, data: function() { … Read more
You can try this in the catch part: catch(error => { if (!error.response) { // network error this.errorStatus=”Error: Network Error”; } else { this.errorStatus = error.response.data.message; } })
The async function consumes a “payload” argument, and secondly a thunkAPI object that contains a getState method. payloadCreator thunkAPI: an object containing all of the parameters that are normally passed to a Redux thunk function, as well as additional options: dispatch: the Redux store dispatch method getState: the Redux store getState method extra: the “extra … Read more
Vue.use means adding plugins. However, axios is not a plugin for Vue, so you can not add it globally via use. My recommendation is importing axios only when you need it. But if you really need to access it globally, you may like to add it to prototype. Vue.prototype.$axios = axios Then you can access … Read more
Items in data like your tickets are made into observable objects. This is to allow reactivity (automatically re-rendering the UI and other features). This is expected and the returned object should behave just like the array. Check out the reactivity docs because you need to interact with arrays in a specific pattern or it will … Read more
axios is the promise so you need to use then to get your result. You should request your api in a separate file and call your action when the result comes back. //WebAPIUtil.js axios.get(‘http://localhost:3000/flug’) .then(function(result){ YourAction.getAllFlights(result) }); In your action file will be like this : export function getAllFlights(request) { console.log(request); return { type: FETCH_FLIGHT, … Read more
Use AxiosError to cast error import { AxiosError } from ‘axios’; catch (error) { const err = error as AxiosError console.log(err.response?.data) }
Axios doesn’t address that situation so far – you can try: process.env.NODE_TLS_REJECT_UNAUTHORIZED = ‘0’; BUT THAT’S A VERY BAD IDEA since it disables SSL across the whole node server. Or, you can configure axios to use a custom agent and set rejectUnauthorized to false for that agent as mentioned here. Example: const https = require(‘https’); … Read more
Axios v0.22.0 and higher As per the documentation, cancellation is now pretty straightforward with the AbortController class instance.interceptors.request.use(config => { /* some logic */ const controller = new AbortController(); if (needToCancelRequest) { controller.abort(); } return { …config, signal: controller.signal }; }); Browser Compatibility You might be tempted to do a pretty concise signal: AbortSignal.abort() instead. … Read more