mergeMap on a list of Ids fails to build









up vote
0
down vote

favorite












What is wrong with the syntax here mergeMap(names => names),?



getIds(): void 
this.myservice
.getIds.pipe( mergeMap(id => this.getNames(id)),
mergeMap(names => names), toArray() )



myservce.ts has the following:



getIds():Observable<Ids>
const url = 'http://localhost:4000';
return this.http
.post(url, '')
.map(( Ids : any) => Ids.map(item => (Id: item.Id,
Name: item.Name ))) as Observable<Ids>;


getNames(data: Ids):Observable<any>
const url ='http://localhost:5000';
return this.http
.post(url,data)
.pipe(map(( Results : any) => Results[0].results.map(item => (Id: item.ID, Name: item.Name ))));



The compiler error is (as a newbie I'm not able to figure out):



ERROR in src/app/cvetable/mcomponent.ts(132,19): error TS2345:
Argument of type '(names: ) => ' is not assignable to parameter
of type '(value: , index: number) => ObservableInput<any>'.
Type '' is not assignable to type 'ObservableInput<any>'.
Type '' is not assignable to type 'Iterable<any>'.
Property '[Symbol.iterator]' is missing in type ''.









share|improve this question























  • can u share the editable stackblitz link
    – NinjaJami
    Nov 10 at 18:50










  • @NinjaJami link is here stackblitz.com/edit/… but doesn't seems to be rigid enough :(
    – Pankaj Parkar
    Nov 10 at 18:51











  • StackBlitz removes the code that doesnt compile :( Hence posting the code above.
    – anglee
    Nov 10 at 19:03










  • could you explain in words what you are trying to accomplish? you seems to stick on mergeMap but maybe this is not suitable for your need ... or maybe it is but without context its hard to tell
    – j3ff
    Nov 10 at 19:24










  • @anglee are you missing () after this.myservice.getIds ?
    – A.Winnen
    Nov 10 at 19:55














up vote
0
down vote

favorite












What is wrong with the syntax here mergeMap(names => names),?



getIds(): void 
this.myservice
.getIds.pipe( mergeMap(id => this.getNames(id)),
mergeMap(names => names), toArray() )



myservce.ts has the following:



getIds():Observable<Ids>
const url = 'http://localhost:4000';
return this.http
.post(url, '')
.map(( Ids : any) => Ids.map(item => (Id: item.Id,
Name: item.Name ))) as Observable<Ids>;


getNames(data: Ids):Observable<any>
const url ='http://localhost:5000';
return this.http
.post(url,data)
.pipe(map(( Results : any) => Results[0].results.map(item => (Id: item.ID, Name: item.Name ))));



The compiler error is (as a newbie I'm not able to figure out):



ERROR in src/app/cvetable/mcomponent.ts(132,19): error TS2345:
Argument of type '(names: ) => ' is not assignable to parameter
of type '(value: , index: number) => ObservableInput<any>'.
Type '' is not assignable to type 'ObservableInput<any>'.
Type '' is not assignable to type 'Iterable<any>'.
Property '[Symbol.iterator]' is missing in type ''.









share|improve this question























  • can u share the editable stackblitz link
    – NinjaJami
    Nov 10 at 18:50










  • @NinjaJami link is here stackblitz.com/edit/… but doesn't seems to be rigid enough :(
    – Pankaj Parkar
    Nov 10 at 18:51











  • StackBlitz removes the code that doesnt compile :( Hence posting the code above.
    – anglee
    Nov 10 at 19:03










  • could you explain in words what you are trying to accomplish? you seems to stick on mergeMap but maybe this is not suitable for your need ... or maybe it is but without context its hard to tell
    – j3ff
    Nov 10 at 19:24










  • @anglee are you missing () after this.myservice.getIds ?
    – A.Winnen
    Nov 10 at 19:55












up vote
0
down vote

favorite









up vote
0
down vote

favorite











What is wrong with the syntax here mergeMap(names => names),?



getIds(): void 
this.myservice
.getIds.pipe( mergeMap(id => this.getNames(id)),
mergeMap(names => names), toArray() )



myservce.ts has the following:



getIds():Observable<Ids>
const url = 'http://localhost:4000';
return this.http
.post(url, '')
.map(( Ids : any) => Ids.map(item => (Id: item.Id,
Name: item.Name ))) as Observable<Ids>;


getNames(data: Ids):Observable<any>
const url ='http://localhost:5000';
return this.http
.post(url,data)
.pipe(map(( Results : any) => Results[0].results.map(item => (Id: item.ID, Name: item.Name ))));



The compiler error is (as a newbie I'm not able to figure out):



ERROR in src/app/cvetable/mcomponent.ts(132,19): error TS2345:
Argument of type '(names: ) => ' is not assignable to parameter
of type '(value: , index: number) => ObservableInput<any>'.
Type '' is not assignable to type 'ObservableInput<any>'.
Type '' is not assignable to type 'Iterable<any>'.
Property '[Symbol.iterator]' is missing in type ''.









share|improve this question















What is wrong with the syntax here mergeMap(names => names),?



getIds(): void 
this.myservice
.getIds.pipe( mergeMap(id => this.getNames(id)),
mergeMap(names => names), toArray() )



myservce.ts has the following:



getIds():Observable<Ids>
const url = 'http://localhost:4000';
return this.http
.post(url, '')
.map(( Ids : any) => Ids.map(item => (Id: item.Id,
Name: item.Name ))) as Observable<Ids>;


getNames(data: Ids):Observable<any>
const url ='http://localhost:5000';
return this.http
.post(url,data)
.pipe(map(( Results : any) => Results[0].results.map(item => (Id: item.ID, Name: item.Name ))));



The compiler error is (as a newbie I'm not able to figure out):



ERROR in src/app/cvetable/mcomponent.ts(132,19): error TS2345:
Argument of type '(names: ) => ' is not assignable to parameter
of type '(value: , index: number) => ObservableInput<any>'.
Type '' is not assignable to type 'ObservableInput<any>'.
Type '' is not assignable to type 'Iterable<any>'.
Property '[Symbol.iterator]' is missing in type ''.






angular http observable






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 18:59

























asked Nov 10 at 18:46









anglee

124




124











  • can u share the editable stackblitz link
    – NinjaJami
    Nov 10 at 18:50










  • @NinjaJami link is here stackblitz.com/edit/… but doesn't seems to be rigid enough :(
    – Pankaj Parkar
    Nov 10 at 18:51











  • StackBlitz removes the code that doesnt compile :( Hence posting the code above.
    – anglee
    Nov 10 at 19:03










  • could you explain in words what you are trying to accomplish? you seems to stick on mergeMap but maybe this is not suitable for your need ... or maybe it is but without context its hard to tell
    – j3ff
    Nov 10 at 19:24










  • @anglee are you missing () after this.myservice.getIds ?
    – A.Winnen
    Nov 10 at 19:55
















  • can u share the editable stackblitz link
    – NinjaJami
    Nov 10 at 18:50










  • @NinjaJami link is here stackblitz.com/edit/… but doesn't seems to be rigid enough :(
    – Pankaj Parkar
    Nov 10 at 18:51











  • StackBlitz removes the code that doesnt compile :( Hence posting the code above.
    – anglee
    Nov 10 at 19:03










  • could you explain in words what you are trying to accomplish? you seems to stick on mergeMap but maybe this is not suitable for your need ... or maybe it is but without context its hard to tell
    – j3ff
    Nov 10 at 19:24










  • @anglee are you missing () after this.myservice.getIds ?
    – A.Winnen
    Nov 10 at 19:55















can u share the editable stackblitz link
– NinjaJami
Nov 10 at 18:50




can u share the editable stackblitz link
– NinjaJami
Nov 10 at 18:50












@NinjaJami link is here stackblitz.com/edit/… but doesn't seems to be rigid enough :(
– Pankaj Parkar
Nov 10 at 18:51





@NinjaJami link is here stackblitz.com/edit/… but doesn't seems to be rigid enough :(
– Pankaj Parkar
Nov 10 at 18:51













StackBlitz removes the code that doesnt compile :( Hence posting the code above.
– anglee
Nov 10 at 19:03




StackBlitz removes the code that doesnt compile :( Hence posting the code above.
– anglee
Nov 10 at 19:03












could you explain in words what you are trying to accomplish? you seems to stick on mergeMap but maybe this is not suitable for your need ... or maybe it is but without context its hard to tell
– j3ff
Nov 10 at 19:24




could you explain in words what you are trying to accomplish? you seems to stick on mergeMap but maybe this is not suitable for your need ... or maybe it is but without context its hard to tell
– j3ff
Nov 10 at 19:24












@anglee are you missing () after this.myservice.getIds ?
– A.Winnen
Nov 10 at 19:55




@anglee are you missing () after this.myservice.getIds ?
– A.Winnen
Nov 10 at 19:55












2 Answers
2






active

oldest

votes

















up vote
0
down vote













There's something seriously wrong with the getIds method in your Service:



Here's how it should be. Since you're using HttpClient and your eg is in Angular 7 which uses Rxjs 6+, you'll have to chain a .pipe call to your Observable value in order to apply operators on it. Inside the .pipe call, you can then place a list of comma separated operators:



getIds(obj):Observable<Ids>
return this.http
.post(this.url, obj)
.pipe(
map((Ids: any) => Ids.map(item => (Id: item.Id, Name: item.Name ) ) )
)



Here's an Updated StackBlitz with the errors fixed.






share|improve this answer




















  • OK. I've made the change. The compile error is still at the same on the line mergeMap(names => names),. Can you please see what I'm missing there?
    – anglee
    Nov 10 at 19:18










  • I'll need you to share a minimal stackblitz sample replicating your issue. The one you shared previously lacks a lot of things. Please fix it so that it replicates just the issue that you're facing. Please fix other issues on the StackBlitz that are there due to not adding implementation details.
    – SiddAjmera
    Nov 10 at 19:24










  • The StackBlitz runs into other issues. Eg. (no Observable module in rxjs/Rx). I'm still working on creating a simpler example with just this problem.
    – anglee
    Nov 10 at 21:10










  • The StackBlitz link has relevant parts of the code. Please take a look. I'm looking to find a fix for the compile failure that seems like a syntax issue.
    – anglee
    Nov 11 at 5:38

















up vote
0
down vote













You should use switchMap instead of mergeMap



getIds(): void 
this.myservice
.getIds.pipe(switchMap(id => this.getNames(id)))






share|improve this answer




















  • OK. But the compile failure is on a diff line. The editable StackBlitz link link has the relevant parts of the code.
    – anglee
    Nov 11 at 5:35










  • Your demo is completely broken. Are expecting others to fix your compilation and syntax issue along with current issue ?
    – Sunil Singh
    Nov 11 at 5:43










  • Sorry; I am only expecting to hear about what is wrong with the syntax in the line that I point out. I cannot post the code because the framework on stackblitz is not the same version as what I have and hence cannot post a working demo with my code.
    – anglee
    Nov 11 at 5:55










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242276%2fmergemap-on-a-list-of-ids-fails-to-build%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













There's something seriously wrong with the getIds method in your Service:



Here's how it should be. Since you're using HttpClient and your eg is in Angular 7 which uses Rxjs 6+, you'll have to chain a .pipe call to your Observable value in order to apply operators on it. Inside the .pipe call, you can then place a list of comma separated operators:



getIds(obj):Observable<Ids>
return this.http
.post(this.url, obj)
.pipe(
map((Ids: any) => Ids.map(item => (Id: item.Id, Name: item.Name ) ) )
)



Here's an Updated StackBlitz with the errors fixed.






share|improve this answer




















  • OK. I've made the change. The compile error is still at the same on the line mergeMap(names => names),. Can you please see what I'm missing there?
    – anglee
    Nov 10 at 19:18










  • I'll need you to share a minimal stackblitz sample replicating your issue. The one you shared previously lacks a lot of things. Please fix it so that it replicates just the issue that you're facing. Please fix other issues on the StackBlitz that are there due to not adding implementation details.
    – SiddAjmera
    Nov 10 at 19:24










  • The StackBlitz runs into other issues. Eg. (no Observable module in rxjs/Rx). I'm still working on creating a simpler example with just this problem.
    – anglee
    Nov 10 at 21:10










  • The StackBlitz link has relevant parts of the code. Please take a look. I'm looking to find a fix for the compile failure that seems like a syntax issue.
    – anglee
    Nov 11 at 5:38














up vote
0
down vote













There's something seriously wrong with the getIds method in your Service:



Here's how it should be. Since you're using HttpClient and your eg is in Angular 7 which uses Rxjs 6+, you'll have to chain a .pipe call to your Observable value in order to apply operators on it. Inside the .pipe call, you can then place a list of comma separated operators:



getIds(obj):Observable<Ids>
return this.http
.post(this.url, obj)
.pipe(
map((Ids: any) => Ids.map(item => (Id: item.Id, Name: item.Name ) ) )
)



Here's an Updated StackBlitz with the errors fixed.






share|improve this answer




















  • OK. I've made the change. The compile error is still at the same on the line mergeMap(names => names),. Can you please see what I'm missing there?
    – anglee
    Nov 10 at 19:18










  • I'll need you to share a minimal stackblitz sample replicating your issue. The one you shared previously lacks a lot of things. Please fix it so that it replicates just the issue that you're facing. Please fix other issues on the StackBlitz that are there due to not adding implementation details.
    – SiddAjmera
    Nov 10 at 19:24










  • The StackBlitz runs into other issues. Eg. (no Observable module in rxjs/Rx). I'm still working on creating a simpler example with just this problem.
    – anglee
    Nov 10 at 21:10










  • The StackBlitz link has relevant parts of the code. Please take a look. I'm looking to find a fix for the compile failure that seems like a syntax issue.
    – anglee
    Nov 11 at 5:38












up vote
0
down vote










up vote
0
down vote









There's something seriously wrong with the getIds method in your Service:



Here's how it should be. Since you're using HttpClient and your eg is in Angular 7 which uses Rxjs 6+, you'll have to chain a .pipe call to your Observable value in order to apply operators on it. Inside the .pipe call, you can then place a list of comma separated operators:



getIds(obj):Observable<Ids>
return this.http
.post(this.url, obj)
.pipe(
map((Ids: any) => Ids.map(item => (Id: item.Id, Name: item.Name ) ) )
)



Here's an Updated StackBlitz with the errors fixed.






share|improve this answer












There's something seriously wrong with the getIds method in your Service:



Here's how it should be. Since you're using HttpClient and your eg is in Angular 7 which uses Rxjs 6+, you'll have to chain a .pipe call to your Observable value in order to apply operators on it. Inside the .pipe call, you can then place a list of comma separated operators:



getIds(obj):Observable<Ids>
return this.http
.post(this.url, obj)
.pipe(
map((Ids: any) => Ids.map(item => (Id: item.Id, Name: item.Name ) ) )
)



Here's an Updated StackBlitz with the errors fixed.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 10 at 19:05









SiddAjmera

9,98721137




9,98721137











  • OK. I've made the change. The compile error is still at the same on the line mergeMap(names => names),. Can you please see what I'm missing there?
    – anglee
    Nov 10 at 19:18










  • I'll need you to share a minimal stackblitz sample replicating your issue. The one you shared previously lacks a lot of things. Please fix it so that it replicates just the issue that you're facing. Please fix other issues on the StackBlitz that are there due to not adding implementation details.
    – SiddAjmera
    Nov 10 at 19:24










  • The StackBlitz runs into other issues. Eg. (no Observable module in rxjs/Rx). I'm still working on creating a simpler example with just this problem.
    – anglee
    Nov 10 at 21:10










  • The StackBlitz link has relevant parts of the code. Please take a look. I'm looking to find a fix for the compile failure that seems like a syntax issue.
    – anglee
    Nov 11 at 5:38
















  • OK. I've made the change. The compile error is still at the same on the line mergeMap(names => names),. Can you please see what I'm missing there?
    – anglee
    Nov 10 at 19:18










  • I'll need you to share a minimal stackblitz sample replicating your issue. The one you shared previously lacks a lot of things. Please fix it so that it replicates just the issue that you're facing. Please fix other issues on the StackBlitz that are there due to not adding implementation details.
    – SiddAjmera
    Nov 10 at 19:24










  • The StackBlitz runs into other issues. Eg. (no Observable module in rxjs/Rx). I'm still working on creating a simpler example with just this problem.
    – anglee
    Nov 10 at 21:10










  • The StackBlitz link has relevant parts of the code. Please take a look. I'm looking to find a fix for the compile failure that seems like a syntax issue.
    – anglee
    Nov 11 at 5:38















OK. I've made the change. The compile error is still at the same on the line mergeMap(names => names),. Can you please see what I'm missing there?
– anglee
Nov 10 at 19:18




OK. I've made the change. The compile error is still at the same on the line mergeMap(names => names),. Can you please see what I'm missing there?
– anglee
Nov 10 at 19:18












I'll need you to share a minimal stackblitz sample replicating your issue. The one you shared previously lacks a lot of things. Please fix it so that it replicates just the issue that you're facing. Please fix other issues on the StackBlitz that are there due to not adding implementation details.
– SiddAjmera
Nov 10 at 19:24




I'll need you to share a minimal stackblitz sample replicating your issue. The one you shared previously lacks a lot of things. Please fix it so that it replicates just the issue that you're facing. Please fix other issues on the StackBlitz that are there due to not adding implementation details.
– SiddAjmera
Nov 10 at 19:24












The StackBlitz runs into other issues. Eg. (no Observable module in rxjs/Rx). I'm still working on creating a simpler example with just this problem.
– anglee
Nov 10 at 21:10




The StackBlitz runs into other issues. Eg. (no Observable module in rxjs/Rx). I'm still working on creating a simpler example with just this problem.
– anglee
Nov 10 at 21:10












The StackBlitz link has relevant parts of the code. Please take a look. I'm looking to find a fix for the compile failure that seems like a syntax issue.
– anglee
Nov 11 at 5:38




The StackBlitz link has relevant parts of the code. Please take a look. I'm looking to find a fix for the compile failure that seems like a syntax issue.
– anglee
Nov 11 at 5:38












up vote
0
down vote













You should use switchMap instead of mergeMap



getIds(): void 
this.myservice
.getIds.pipe(switchMap(id => this.getNames(id)))






share|improve this answer




















  • OK. But the compile failure is on a diff line. The editable StackBlitz link link has the relevant parts of the code.
    – anglee
    Nov 11 at 5:35










  • Your demo is completely broken. Are expecting others to fix your compilation and syntax issue along with current issue ?
    – Sunil Singh
    Nov 11 at 5:43










  • Sorry; I am only expecting to hear about what is wrong with the syntax in the line that I point out. I cannot post the code because the framework on stackblitz is not the same version as what I have and hence cannot post a working demo with my code.
    – anglee
    Nov 11 at 5:55














up vote
0
down vote













You should use switchMap instead of mergeMap



getIds(): void 
this.myservice
.getIds.pipe(switchMap(id => this.getNames(id)))






share|improve this answer




















  • OK. But the compile failure is on a diff line. The editable StackBlitz link link has the relevant parts of the code.
    – anglee
    Nov 11 at 5:35










  • Your demo is completely broken. Are expecting others to fix your compilation and syntax issue along with current issue ?
    – Sunil Singh
    Nov 11 at 5:43










  • Sorry; I am only expecting to hear about what is wrong with the syntax in the line that I point out. I cannot post the code because the framework on stackblitz is not the same version as what I have and hence cannot post a working demo with my code.
    – anglee
    Nov 11 at 5:55












up vote
0
down vote










up vote
0
down vote









You should use switchMap instead of mergeMap



getIds(): void 
this.myservice
.getIds.pipe(switchMap(id => this.getNames(id)))






share|improve this answer












You should use switchMap instead of mergeMap



getIds(): void 
this.myservice
.getIds.pipe(switchMap(id => this.getNames(id)))







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 11 at 4:24









Sunil Singh

5,4571625




5,4571625











  • OK. But the compile failure is on a diff line. The editable StackBlitz link link has the relevant parts of the code.
    – anglee
    Nov 11 at 5:35










  • Your demo is completely broken. Are expecting others to fix your compilation and syntax issue along with current issue ?
    – Sunil Singh
    Nov 11 at 5:43










  • Sorry; I am only expecting to hear about what is wrong with the syntax in the line that I point out. I cannot post the code because the framework on stackblitz is not the same version as what I have and hence cannot post a working demo with my code.
    – anglee
    Nov 11 at 5:55
















  • OK. But the compile failure is on a diff line. The editable StackBlitz link link has the relevant parts of the code.
    – anglee
    Nov 11 at 5:35










  • Your demo is completely broken. Are expecting others to fix your compilation and syntax issue along with current issue ?
    – Sunil Singh
    Nov 11 at 5:43










  • Sorry; I am only expecting to hear about what is wrong with the syntax in the line that I point out. I cannot post the code because the framework on stackblitz is not the same version as what I have and hence cannot post a working demo with my code.
    – anglee
    Nov 11 at 5:55















OK. But the compile failure is on a diff line. The editable StackBlitz link link has the relevant parts of the code.
– anglee
Nov 11 at 5:35




OK. But the compile failure is on a diff line. The editable StackBlitz link link has the relevant parts of the code.
– anglee
Nov 11 at 5:35












Your demo is completely broken. Are expecting others to fix your compilation and syntax issue along with current issue ?
– Sunil Singh
Nov 11 at 5:43




Your demo is completely broken. Are expecting others to fix your compilation and syntax issue along with current issue ?
– Sunil Singh
Nov 11 at 5:43












Sorry; I am only expecting to hear about what is wrong with the syntax in the line that I point out. I cannot post the code because the framework on stackblitz is not the same version as what I have and hence cannot post a working demo with my code.
– anglee
Nov 11 at 5:55




Sorry; I am only expecting to hear about what is wrong with the syntax in the line that I point out. I cannot post the code because the framework on stackblitz is not the same version as what I have and hence cannot post a working demo with my code.
– anglee
Nov 11 at 5:55

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242276%2fmergemap-on-a-list-of-ids-fails-to-build%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3