Pipeline
Introduction
Pipeline style allows you use to chain your promise using the pipe operator |>
.
Writing your code using the pipeline style makes your code looks similar to what you would write in JavaScript.
JavaScript
fetch('https://my-api.com/users')
.then(function (response) {
return fetch('https://my-api.com/posts')
})
.then(function (response) {
// Done, do something with the result
})
.catch(function (req) {
// An error ocurred
})
F#
fetch "https://my-api.com/users"
|> Promise.map (fun response ->
fetch "https://my-api.com/posts"
)
|> Promise.map (fun response ->
// Done, do something with the result
)
|> Promise.catch (fun error ->
// An error ocurred
)
You can find all the available function with examples here