Skip to content

Url.variables.setSearchParams

fx-fetch


fx-fetch / Url / setSearchParams

const setSearchParams: {(url, params): Url; (params): (url) => Url; }

Defined in: packages/fx-fetch/src/Url/setSearchParams.ts:65

Sets or updates multiple search parameters in the existing URL’s query string.

(url, params): Url

Sets or updates multiple search parameters in the existing URL’s query string.

Url

SearchParamsInput

Url

import { Url } from 'fx-fetch';
const url = Url.unsafeMake({
url: 'https://example.com',
searchParams: {
tag: ['new', 'sale'],
},
});
Url.format(url); // 'https://example.com?tag=new&tag=sale'
// Set 'tag' parameter to 'active', replacing existing values
url.pipe(
Url.setSearchParams({
"tag": "active"
}),
Url.format // 'https://example.com?tag=active'
);
// Add new 'q' parameter without removing existing ones
url.pipe(
Url.setSearchParams({
"q": "Lorem ipsum",
}),
Url.format // 'https://example.com?tag=new&tag=sale&q=Lorem+ipsum'
);

0.1.0

(params): (url) => Url

Sets or updates multiple search parameters in the existing URL’s query string.

SearchParamsInput

(url): Url

Url

Url

import { Url } from 'fx-fetch';
const url = Url.unsafeMake({
url: 'https://example.com',
searchParams: {
tag: ['new', 'sale'],
},
});
Url.format(url); // 'https://example.com?tag=new&tag=sale'
// Set 'tag' parameter to 'active', replacing existing values
url.pipe(
Url.setSearchParams({
"tag": "active"
}),
Url.format // 'https://example.com?tag=active'
);
// Add new 'q' parameter without removing existing ones
url.pipe(
Url.setSearchParams({
"q": "Lorem ipsum",
}),
Url.format // 'https://example.com?tag=new&tag=sale&q=Lorem+ipsum'
);

0.1.0

import { Url } from 'fx-fetch';
const url = Url.unsafeMake({
url: 'https://example.com',
searchParams: {
tag: ['new', 'sale'],
},
});
Url.format(url); // 'https://example.com?tag=new&tag=sale'
// Set 'tag' parameter to 'active', replacing existing values
url.pipe(
Url.setSearchParams({
"tag": "active"
}),
Url.format // 'https://example.com?tag=active'
);
// Add new 'q' parameter without removing existing ones
url.pipe(
Url.setSearchParams({
"q": "Lorem ipsum",
}),
Url.format // 'https://example.com?tag=new&tag=sale&q=Lorem+ipsum'
);

0.1.0