Answers for "axios typescript"

1

nuxt typescript $axios types

Add the types to your "types" array in tsconfig.json
after the @nuxt/types (Nuxt 2.9.0+) or @nuxt/vue-app entry

--------------------------------------------------------
tsconfig.json

{
  "compilerOptions": {
    "types": [
      "@nuxt/types",
      "@nuxtjs/axios"
    ]
  }
}
-------------------------------------------------------
Posted by: Guest on December-20-2020
2

typescript axios

interface User {
    id: number;
    firstName: string;
}


axios.get<User[]>('http://localhost:8080/admin/users')
        .then(response => {
            console.log(response.data);
            setUserList( response.data );
        });
Posted by: Guest on June-17-2021
2

axios typescript

axios.request<ServerData>({
  url: 'https://example.com/path/to/data',
  transformResponse: (r: ServerResponse) => r.data
}).then((response) => {
  // `response` is of type `AxiosResponse<ServerData>`
  const { data } = response
  // `data` is of type ServerData, correctly inferred
})
Posted by: Guest on February-03-2021

Code answers related to "TypeScript"

Browse Popular Code Answers by Language