nuxt / http

Universal HTTP Module for Nuxt.js
https://http.nuxtjs.org
MIT License
229 stars 51 forks source link

$http type not found in context while using @nuxtjs/composition-api #166

Closed JaviOverflow closed 3 years ago

JaviOverflow commented 3 years ago

Doing

const { $http } = useContext()
$http.$post(...)

$post is highlighted as not found in type. For some reason, it doesn't find the types for $http.

I'm using "@nuxt/http": "^0.6.2" and included the module in nuxt.config.js like so:

  modules: ['@nuxt/http'],

I'm already using other modules and buildModules, and they get their types inferred correctly. I'm not sure how to fix this or what I'm doing wrong.

I'm using the following versions:

    // dependencies
    "nuxt": "^2.15.0",
    "@nuxt/typescript-runtime": "^2.0.1",
    "@nuxtjs/composition-api": "^0.20.1",

    // devDependencies
    "@nuxt/types": "^2.15.0",
    "@nuxt/typescript-build": "^2.0.4",
JaviOverflow commented 3 years ago

Adding @nuxt/http to the types at tsconfig.json solved the issue. Sorry for opening the issue.