0

How to use dynamic url for http-request in total.js flow. I am able to get params from route component but how to pass this to http-request url ?

enter image description here

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Pritam Parua
  • 672
  • 2
  • 8
  • 27

1 Answers1

0

It's possible and it's very easy. You can use Code (better) or Repository component.

  • add Code component with this code:
// This will be as dynamic argument stored in hidden Flow Message repository:
repository.code = 'sk';

// or you can bind value from received data:
repository.code = value.code; // value === received data

// Continue with processing
send(0, value);
  • now you can update URL address in HTTP Request component like this:
URL: https://restcountries.eu/rest/v2/alpha/{code}

HTTP Request component will replace {code} for repository.code value. You can use multiple values. That's all :-)

Peter Sirka
  • 748
  • 5
  • 10
  • But as i am understanding from repository.code = 'sk'; code will be always sk. I need something repository.code = flowdata.data.params.id an its a simple param pass. Do we need to store in repository ? @peter-sirka – Pritam Parua Jan 08 '19 at 18:45
  • I have updated answer. Read carefully info in "Code" component, here is https://github.com/totaljs/flowcomponents/tree/master/code ... You can bind a value from message easily via "value.YOUR_KEY". – Peter Sirka Jan 08 '19 at 19:04