Bekacru / better-fetch

Advanced fetch wrapper for typescript
https://better-fetch.vercel.app/
210 stars 7 forks source link

Query Value not being set #12

Open AdzeB opened 3 months ago

AdzeB commented 3 months ago

Query value is not being set even with hardCoded value

Request:

  const { data, error } = await $fetch("@post/device/unlinkButton", {
      query: {
        userId: userData.id || 0,
      },
    });

LOG:

 LOG  info  Request being sent to: https://api_here.com/api/device/unlinkButton
 LOG  fail  Request failed with status:  400 (Bad Request)
 LOG  error {"message": "Value cannot be null. (Parameter 's')", "status": 400, "statusCode": "400", "statusText": ""}
 LOG  12:23:34 | ERROR : Error unlinking button: 
{
  "status": 400,
  "statusCode": "400",
  "message": "Value cannot be null. (Parameter 's')",
  "statusText": ""
}

Set Up

image
Bekacru commented 3 months ago

Hey, I tried to take a look and it seems like it should be working. The screenshot below works correctly. To better understand the issue you're experiencing, could you please provide a reproducible example? A CodePen, JSFiddle, or a similar online code editor link would be very helpful.

code

AdzeB commented 3 months ago

Hi I added the customFetchImpl to log it

Impl

  const { data, error } = await $fetch("@post/device/unlinkButton", {
      query: { userId: 10 },
    });

LOGs:

LOG  info  Request being sent to: https://api.here.com/api/device/unlinkButton  
LOG  false  
LOG  {}  
LOG  fail  Request failed with status:  400 (Bad Request)  
LOG  Retrying request. Attempted Request: https://api.here.com/api/device/unlinkButton, Attempted Response: 400  
WARN  warn  Retrying request... Attempt: 1  
LOG  info  Request being sent to: https://api.here.com/api/device/unlinkButton  
LOG  false  
LOG  {}  
LOG  fail  Request failed with status:  400 (Bad Request)  
LOG  Retrying request. Attempted Request: https://api.here.com/api/device/unlinkButton, Attempted Response: 400  
WARN  warn  Retrying request... Attempt: 2  
LOG  info  Request being sent to: https://api.here.comt/api/device/unlinkButton  
LOG  false  
LOG  {}  
LOG  fail  Request failed with status:  400 (Bad Request)  
LOG  Retrying request. Attempted Request: https://api.here.com/api/device/unlinkButton, Attempted Response: 400  
WARN  warn  Retrying request... Attempt: 3  
LOG  info  Request being sent to: https://api.here.com/api/device/unlinkButton  
LOG  false  
LOG  {}  
LOG  fail  Request failed with status:  400 (Bad Request)  
LOG  error {"message": "Value cannot be null. (Parameter 's')", "status": 400, "statusCode": "400", "statusText": ""}  
LOG  17:52:17 | ERROR : Error unlinking button:   
{  
 "status": 400,  
 "statusCode": "400",  
 "message": "Value cannot be null. (Parameter 's')",  
 "statusText": ""  
}  
Bekacru commented 3 months ago

Hi I added the customFetchImpl to log it

Impl

  const { data, error } = await $fetch("@post/device/unlinkButton", {
      query: { userId: 10 },
    });

LOGs:

LOG  info  Request being sent to: https://api.here.com/api/device/unlinkButton  
LOG  false  
LOG  {}  
LOG  fail  Request failed with status:  400 (Bad Request)  
LOG  Retrying request. Attempted Request: https://api.here.com/api/device/unlinkButton, Attempted Response: 400  
WARN  warn  Retrying request... Attempt: 1  
LOG  info  Request being sent to: https://api.here.com/api/device/unlinkButton  
LOG  false  
LOG  {}  
LOG  fail  Request failed with status:  400 (Bad Request)  
LOG  Retrying request. Attempted Request: https://api.here.com/api/device/unlinkButton, Attempted Response: 400  
WARN  warn  Retrying request... Attempt: 2  
LOG  info  Request being sent to: https://api.here.comt/api/device/unlinkButton  
LOG  false  
LOG  {}  
LOG  fail  Request failed with status:  400 (Bad Request)  
LOG  Retrying request. Attempted Request: https://api.here.com/api/device/unlinkButton, Attempted Response: 400  
WARN  warn  Retrying request... Attempt: 3  
LOG  info  Request being sent to: https://api.here.com/api/device/unlinkButton  
LOG  false  
LOG  {}  
LOG  fail  Request failed with status:  400 (Bad Request)  
LOG  error {"message": "Value cannot be null. (Parameter 's')", "status": 400, "statusCode": "400", "statusText": ""}  
LOG  17:52:17 | ERROR : Error unlinking button:   
{  
 "status": 400,  
 "statusCode": "400",  
 "message": "Value cannot be null. (Parameter 's')",  
 "statusText": ""  
}  

The issue you're experiencing should generally work, and we have test cases that cover this scenario. To better identify the problem, could you please provide a link to the code in a reproducible format? A github link or online code editors like the ones I suggested above would be great.

AdzeB commented 3 months ago

Okay, no problem I will create it