davidedantonio / fastify-axios Goto Github PK
View Code? Open in Web Editor NEWAdd axios http client to your fastify instance
License: MIT License
Add axios http client to your fastify instance
License: MIT License
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?
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?
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",
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?
Please look at this new vulnerability
Auditing my Fastify project, it looks like the dependency is indeed on fastify-axios
└─┬ [email protected]
└─┬ [email protected]
├─┬ @isaacs/[email protected]
│ └─┬ @babel/[email protected]
│ ├─┬ @babel/[email protected]
│ │ └── @babel/[email protected] deduped
│ └── @babel/[email protected]
Could you please fix the dependency?
how to set cookie when send HTTP on axios.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.