Using Base URL — Mocking REST API with Mock Service Worker

preview_player
Показать описание
In this recipe, you will learn how to provide a base URL to your request handlers using Mock Service Worker. We encourage you to create custom functions around the setup you need, including functions like "gitHubApi" to resolve relative paths to absolute service URLs.

* * *

#javascript #msw #mock
Рекомендации по теме
Комментарии
Автор

Using a base URL is hands-down one of the most frequent questions we get. That's why we've decided to record a short video showcasing how you can achieve that in your handlers. Our goal here is to encourage you to think about your handlers as plain functions which you can compose to achieve your particular scenario. Let us know in the comments if you find short videos like this useful!

ApiMocking
Автор

Wouldn't it be easier if you made a constant with a template literal, adding the path at the end?

andreidanciu