nanotime / http-please Goto Github PK
View Code? Open in Web Editor NEWA simple http fetch wrapper to use with TS
License: MIT License
A simple http fetch wrapper to use with TS
License: MIT License
Is your feature request related to a problem? Please describe.
The plugin need an inner full fetch instance to use internally on the different methods. This allows the users to use full vanilla fetch if they want and create inner instances with their own config.
Describe the solution you'd like
The method could be used like:
const instance = new HttpPlease({ ... });
instance.fetch(url, options); // using the full fetch API.
Describe alternatives you've considered
...
Additional context
This is primarily for better dev experience and sensibility.
Is your feature request related to a problem? Please describe.
FormatUrl should be a chain plugin instead an internal private use. At this moment formatUrl is a plugin used internally that only return a string, not a chain.
Describe the solution you'd like
I want to create the first plugin as an example, it has to be importable and it has to be added in the construction of the instance instead of being directly included in the execution, something like this:
import CreateHttpPlease from '@nanotime/http-please;
import { query } from '@nanotime/http-please/plugins';
const http = CreateHttpPlease({
url: 'https://example.com',
options: { ... },
plugins: [
query,
]
})
const getSomething = async () => {
const request = await http.query({ foo: 'bar' }).get({ path: '/baz' });
return reques.data
}
Related with #17
Is your feature request related to a problem? Please describe.
Library needs documentation about usage, collaboration, repository rules and PR templates.
Additional context
Here's how to create all the correct files
Is your feature request related to a problem? Please describe.
Don't find any real use for TS in this library
Is your feature request related to a problem? Please describe.
This project is meant to have some default importable plugins but it need a different configuration for that.
Describe the solution you'd like
This article can be useful
Is your feature request related to a problem? Please describe.
The lib needs the capacity to select the method response resolver, can be any of the Response methods defined in fetch documentation
Describe the solution you'd like
interface HttpPlease {
ur: URL;
options: RequestInit
resolver: string;
}
new HttpPlease({
...
resolver: 'json'
})
Additional context
Response Class
Describe the bug
Request interceptor is exposing the response object.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
It should log the configuration you have on the instance and request, not the response
Is your feature request related to a problem? Please describe.
The lib need more test coverage
Describe the bug
Wrong exporting on plugins multi entry points
To Reproduce
Steps to reproduce the behavior:
Expected behavior
It should import the function.
Screenshots
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Is your feature request related to a problem? Please describe.
This library needs a flexible plugins system to extends functionality.
Describe the solution you'd like
A plugin system like this one:
const instance = new HttpPlease({ url, options, plugins: [pluginA, pluginB, pluginC] });
instance.get(...).pluginA().pluginB().pluginC();
Describe alternatives you've considered
I'm thinking on extend this just with functions that consimes this
context on the Class.
Additional context
Need more research.
This library need to be typed to be used accordingly in TS projects, but at this moment is written in Vanilla JS.
The solution I'll like is to create a declaration file and keep the JS code as it is.
Here is a draft for the d.ts file
I also considered a TS migration but not sure of it.
The biggest problem here is how to type the plugins system since that feature is pretty open. A plugin is only a function that returns an object, that object is injected on the instance creator and it can be whatever you need this is an optional plugin example and this is a more complex one.
Truth is that this structure is really flexible and useful to extend the library but a pain to type, so maybe a refactor of the plugin system for a more structured way would be a solution for this.
main
branch failed. π¨I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. Iβm sure you can fix this πͺ.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the main
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here are some links that can help you:
If those donβt help, or if this issue is reporting something you think isnβt right, you can always ask the humans behind semantic-release.
semantic-release cannot push the version tag to the branch main
on the remote Git repository with URL https://x-access-token:[secure]@github.com/nanotime/http-please.git
.
This can be caused by:
Good luck with your project β¨
Your semantic-release bot π¦π
Describe the bug
Query method is doing the correct job but is not chaining correctly on the prototype,, trying to use it as expected triggers an error like:
Uncaught TypeError: http.query(...).get is not a function
To Reproduce
Steps to reproduce the behavior:
Just try to call any prototype method after .query
and you'll get the error.
Expected behavior
It should configure the query string for you and inject it into the URL
Screenshots
N/A
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.