You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to use the following code to generate 400 response and it did not work.So what is the right way to generate a 400 or 403 response with mock.js? Thank you very much.
export default {
getCurve: config => {
console.log(config)
const {curve_index,test_id}=param2Obj(config.url)
let results = [];
let curve1 = [];
let curve2 = [];
let curve3 = [];
for (let i = 0; i < 3000; i++) {
curve1.push(Math.random() * 300)
}
results.push(curve1)
for (let i = 0; i < 3000; i++) {
curve2.push(Math.random() * 500)
}
results.push(curve2)
for (let i = 0; i < 3000; i++) {
curve3.push(Math.random() * 700)
}
results.push(curve3)
console.log(results)
if (test_id == '1234') {
if (curve_index < 2) {
return {
code: 200,
data: results[curve_index],
count_data: 3
}
}
else {
return {
status: 400,
data: results[curve_index],
count_data: 3
}
}
}
}
}
I tried to use the following code to generate 400 response and it did not work.So what is the right way to generate a 400 or 403 response with mock.js? Thank you very much.
The response that code generate :
The text was updated successfully, but these errors were encountered: