I try to create a single text by joining the result of multiple requests.
A small library application lists the author of a book. Using the Openlibrary Books API information about the authors is queried. But instead of listing the author name, they redirect using identifiers.
How to do multiple requests and join the results in a single text property?
Reading the documentation and examples, I thought it would be possible to use join for that. For each element a value “function” can be provided. I couldn’t figure out how to implement it.
I also tried to create a lambda function that returned a string value. But that yields the error:
valid 'target' found for 'type' option 'target'. Unexpected 'target':
- expected: 'descriptor'
- but found: 'none'
The first request looks like this:
let $'ISBN Informatie' = ^ $'res'.'content' => call 'unicode'::'import' with ( $'encoding' = "UTF-8" ) => parse as JSON => decorate as {
'title': text
'covers': list integer
'authors': list {
'key': text
}
}
Maybe call http?
'Auteur' = $'ISBN Informatie'.'authors' => join separator: ( ", " ) ( => call 'network'::'http'
(
$'server' = "https://openlibrary.org"
$'path' = list ( $ .'key', ".json" ) => join ( )
$'authentication' = unset
$'request' = new (
'method' = option 'get'
)
)