Code Monkey home page Code Monkey logo

fastify-axios's People

Contributors

cwsalbirex avatar davidedantonio avatar dependabot[bot] avatar greenkeeper[bot] avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fastify-axios's Issues

Typescript support

Hello - I'm very new to both Fastify and Typescript, but is there a simple way to support this plugin in a Fastify x Typescript app? When attempting to import this plugin I'm getting a No overload matches this call. error - which I'm guessing is because there are no types. Would I just be able to simply add the Axios types and declare them somewhere?

Not working with TypeScript: Could not find a declaration file for module 'fastify-axios'.

I have installed this plugin according to the README with npm install fastify-axios.

But I can't require it as written in README. Instead I get the error:

import fastifyAxios from 'fastify-axios';
...
await server.register(fastifyAxios, {

[ERROR] 19:05:22 ⨯ Unable to compile TypeScript:
src/index.ts(4,26): error TS7016: Could not find a declaration file for module 'fastify-axios'.

How can I use this plugin with TypeScript?

Add Types?

Hello there.

I have a project im working on thats written in TS and i had a hard time figuring it out to work with types.

I had to include a index.d.ts inside the module folder (i know this is horrible practice) and is still not working how it should.

I know it's not enough to open a PR and i would love someone pointing me to the right direction here.

index.d.ts inside node_modules/fastify-axios folder:

import { FastifyPluginCallback } from 'fastify'
import { AxiosDefaults,AxiosRequestHeaders } from 'axios'
import fastify from 'fastify'

declare module 'fastify-axios'

export interface AxiosOpts {
  clients?: {
    [name: string]: {
      baseUrl?: string,
      headers?: AxiosRequestHeaders
    }
  }
}

declare const fastifyAxios: FastifyPluginCallback<AxiosOpts?>

declare module 'fastify' {
  export interface FastifyInstance {
    axios: {
      [name: string]: FastifyPluginCallback
    }
  }
}

export default fastifyAxios
export { fastifyAxios }

I'm using:
"fastify": "^4.3.0",
"fastify-axios": "^1.2.5",
"axios": "^0.27.2",

How to update bearer token in clients?

When i use this construction:

fastify.register(require('fastify-axios'), {
    clients: {
      v1: {
        baseURL: 'https://v1.api.com',
        headers: {
          'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJxyz'
        }
      },
  })

how i can update headers before i send new request?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.