Comments (4)
My suggestion would be to use
this.http.request<MyModel>(
this.flag ? 'post' : 'put',
'http://api.com/test',
{}
);
from angular.
Yeah the client have a ton of overloads, it's better to not have a dynamic method to infer the types.
The workaround proposed by JB is the right solution.
from angular.
For the Googlers: When sending data, the invocation
this.http[ booleanFlag ? 'post' : 'put']<MyModel>('http://api.com/test', theData, options)
becomes
this.http.request<MyModel>(booleanFlag ? 'post' : 'put', 'http://api.com/test', {body: theData, ...options})
Note that the data you’re sending becomes part of the options.
from angular.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
from angular.
Related Issues (20)
- Allow Embed of Docs for Use in a Certification Exam from certificates.dev HOT 2
- docs-infra: Can't serve locally adev HOT 2
- docs (docs-infra): add the ability to filter API references on developer preview/experimental
- Missing padding for CLI command block in the header of CLI Reference.
- Add an option to disallow concrete root providers to be used in TestBed HOT 3
- Model inputs not working as expected HOT 4
- docs (docs-infra): provide links to mentioned API references on API reference detail pages HOT 1
- Allow Resolve implementations to return RedirectCommand
- public getter for reactive properties in abstractControl HOT 3
- `ngtypecheck` reference added in compiled TS files for libraries with multiple secondary entrypoints HOT 1
- Wrong warning about not animatable properties HOT 1
- defer block tutorial glitch HOT 2
- Allow NgOptimizedImage to work with predefined srcset
- Router Outlet adds component after the current component HOT 3
- ページにアクセスできない HOT 1
- Page Not Found https://angular.jp/api/core/for HOT 2
- @if condition narrowing doesn't match typescript behaviour HOT 2
- TypeScript 5.6 causes NG3 error HOT 3
- Feature request: Enhanced Control and Feedback for Service Worker Registration and Caching
- [vite] Internal server error: ASSERTION ERROR: Expected [Text|Element|Container|ElementContainer|Projection|IcuContainer] but got LetDeclaration. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular.