I have to make a post request to sort of complex url :http://localhost:8080/api/login?email=example%40gmail.com&password=examplepassword according to swagger-ui. The examples at axios's github page says that the second parameter is an object. In my example the second parameter must include email and password properties but after that? I tried many ways to pull this situation of. One of these is below. By the way this error occurs: xhr.js:187 POST http://localhost:8080/api/login?email=asdsadsad&password=[object%20Object]
CustomerSlice:
const customerService = new CustomerService()
export const logCustomerIn = createAsyncThunk(
'customer/logCustomerIn',
async (email, password)=>{
// const response = await customerService.logCustomerIn(email, password)
const response = await axios.post(`http://localhost:8080/api/login?email=${email}&password=${password}`)
console.log(response)
return response.data.success
}
)
export const getCustomers = createAsyncThunk(
'customer/getCustomers',
async ()=>{
const response = await customerService.getAll()
return response.data.data
}
)
export const getCustomerByEmail = createAsyncThunk(
'customer/getCustomerById',
async(email)=>{
const response = await customerService.getCustomerByEmail(email)
console.log(response)
return response.data.data
}
)
export const customerSlice = createSlice({
name:'customer',
initialState: {
items:[],
currentCustomer:{},
loggedIn:false,
},
reducers:{},
extraReducers:{
[logCustomerIn.fulfilled]:(state,action)=>{
state.loggedIn = true
console.log("logcustomer fulfilled")
},
[getCustomers.fulfilled]:(state,action)=>{
state.items = action.payload
},
[getCustomerByEmail.fulfilled]: (state,action)=>{
state.currentCustomer = action.payload
console.log(state.currentCustomer)
}
}
})
export default customerSlice.reducer