rtk: Add base to url and fix mock handler
This commit is contained in:
parent
797ceddcd1
commit
a1a49806e1
9 changed files with 3670 additions and 5233 deletions
|
|
@ -16,9 +16,9 @@ type RequestTypes = 'GET' | 'PUT' | 'POST' | 'DELETE';
|
|||
|
||||
export function spyOnRequest(pathname: string, method: RequestTypes) {
|
||||
return new Promise((resolve) => {
|
||||
// @ts-expect-error Parameter 'name' implicitly has an 'any' type.ts(7006)
|
||||
const listener = async (req) => {
|
||||
if (req.url.pathname === pathname && req.method === method) {
|
||||
const listener = async ({ request: req }: { request: Request }) => {
|
||||
const url = new URL(req.url);
|
||||
if (url.pathname === pathname && req.method === method) {
|
||||
const requestData = await req.clone().json();
|
||||
resolve(requestData);
|
||||
// Cleanup listener after successful intercept
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue