Skip to content

Recursive fetch doesn't work on server-side #5168

@rosieks

Description

@rosieks

I tried to run such code on server-side but for some reason it doesn't work. fetch function is imported from domain-task

return fetch('https://jsonplaceholder.typicode.com/posts/1')
    .then(response => response.json())
    .then(response => {
        return fetch('https://jsonplaceholder.typicode.com/posts/2')
            .then(response2 => response2.json())
    });

I receive the following error:

Exception: Call to Node module failed with error: Error: 
When running outside the browser (e.g., in Node.js), you must specify a base URL
before invoking domain-task's 'fetch' wrapper.
Example:
import { baseUrl } from 'domain-task/fetch';
baseUrl('http://example.com'); // Relative URLs will be resolved against this

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesfeature-spa

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions