-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unable to get the same response when using fetch method #552
Comments
Query params are not HTTP header. Set query params as follows. const url = 'https://example.com/sss/ssss/ssss/207'
const params = new URLSearchParams({ name: value })
.fetch(url + '?' + params {
method: 'GET',
}) |
i have tried it getting the same response
if i removed qs.stringfy from params i get this response
|
I think this can generate same URL. const url = new URL('https://example.com/sss/ssss/ssss/207');
url.searchParams.append('additionalParams[include][0]', 'Platforms');
url.searchParams.append('additionalParams[include][1]', 'Platforms.PlatformType');
url.searchParams.append('additionalParams[include][2]', 'Platforms.PlatformMobileOperator');
url.searchParams.append('additionalParams[include][3]', 'Platforms.PlatformSatelliteOperator');
url.searchParams.append('additionalParams[include][4]', 'Country');
url.searchParams.append('additionalParams[include][5]', 'State');
console.log(url.href);
/*
https://example.com/sss/ssss/ssss/207?additionalParams%5Binclude%5D%5B0%5D=Platforms&additionalParams%5Binclude%5D%5B1%5D=Platforms.PlatformType&additionalParams%5Binclude%5D%5B2%5D=Platforms.PlatformMobileOperator&additionalParams%5Binclude%5D%5B3%5D=Platforms.PlatformSatelliteOperator&additionalParams%5Binclude%5D%5B4%5D=Country&additionalParams%5Binclude%5D%5B5%5D=State
*/ |
still same however console.log(url.herf) it prints the exact request url that i see in browser network tab
|
Query params look correct. |
To see what value is affecting, first request with the same HTTP header. |
@H1Gdev it still ignoring the additional params and get the response for the url without aditional params in the code below
|
First, set all values here and test. By the way, do you know this Web API specifications? |
i already did that, getting same response , its ignoring the additional params
|
Please delete |
@H1Gdev
|
Replace setup values. .setup({
request: {
redirect: 'manual',
headers: {
'content-type': 'application/json',
'accept': 'application/json, text/plain, */*',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'en-US,en;q=0.9,ar;q=0.8,bs;q=0.7',
// 'client-request-id': 'id_jd23j9jj4',
'company-service': 'default',
'origin': ' https://mc.test.att.com',
'referer': 'https://mc.test.att.com/companies/207',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-site',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.116 Safari/537.36'
}
}
}, true) |
@H1Gdev it returns 200,but again send the regular response and ignoring the additional params |
I forgot this option... .fetch(url.href, {
method: 'Get',
}, {
urlEncode: false,
}) I think this is issue cause, so I don't think that HTTP header settings are necessary. |
YUP, finally!! just a quick one, when i should add urlEncode to true or false |
If build URL using URL as in this case, it is already URL-encoded. In case it is not necessary, so |
im tryin to test an API that use get method and also contains additional params in request headers (query string params)
but im getting only this response
instead of this response that im getting from network in browser as shown below
The text was updated successfully, but these errors were encountered: