Angular 6 multiple HTTP request RxJs

E Doe

I am new to Angular 6 and having hard time grasping MergeMap and ConcatMap. What i'm trying to achieve is making an API call that returns following example:

JSON object

Json object

I need to take all the inputDatasets.datasetName comma separated to a string and make another api call with that api call will return inputDatasets.version array to update the first API call. I see so many different uses of map and pipe and mergeMap concatMap and little overwhelmed as to which to use and how to implement.

Adrian Brand

I would use switchMap

service.getSpreadSheetdata().pipe(
    map(spreadSheetdata => transformSpreadSheetdata(spreadSheetdata)),
    switchMap(transformedSpreadSheetdata => service.apiCall(transformedSpreadSheetdata))
).subscribe(apiData => doStuffWithApiData(apiData));

Call the method to get the spread sheet data, then map it to the shape you need for the api call and then switch map the transformed data to pass it down to the api call.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

  1. 1

    What exactly is memory mapped io and port based io

  2. 2

    How i extract text from a model dialog in selenium?

  3. 3

    pump.io port in URL

  4. 4

    Selenium browsing with headless isn't working?

  5. 5

    change TabView indicator SwiftUI

  6. 6

    python requests How to send data to a website

  7. 7

    Kubernetes pods not starting, running behind a proxy

  8. 8

    Scaffold-DbContext returns System.ArgumentNullException: Parameter name: proposedIdentifier in EFCore 2.0 when trying to pluralize

  9. 9

    Java POI: How to find an Excel cell with a string value and get its position (row) to use that position to find another cell

  10. 10

    Creating interaction sessions based on timestamps in pandas

  11. 11

    Maven annotation processing processor not found

  12. 12

    Missing field when deserializing using Jackson (Polymorphic)

  13. 13

    Spring Data JPA repository methods don't recognize property names with underscores

  14. 14

    Get all Woocommerce products from current product category term Id in a WP_Query

  15. 15

    How to update if key exists - sequelize

  16. 16

    I got message for error_log file "The stream or file ".../laravel.log" could not be opened: failed to open stream: Permission denied"

  17. 17

    Servlet: HTTP Status 404 - Not Found

  18. 18

    Type 'Moment' is not assignable to type 'Date'. Property 'toDateString' is missing in type 'Moment'

  19. 19

    what is key in CTTelephonyNetworkInfo().serviceSubscriberCellularProviders and CTTelephonyNetworkInfo().serviceCurrentRadioAccessTechnology

  20. 20

    Laravel(ajax) 404 not found

  21. 21

    Error: Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters

HotTag

Archive