How can I debug this problem? I can find no information to follow.
I have the following saga:
export function* generateSoftwareLicenseCode({distributor, licenseType, duration}: GenerateSoftwareLicenseCodeAction) {
const username = getUsername();
const jwtToken = yield call(getJwtToken, username);
const link = new HttpLink({
uri: getGraphqlEndpointUrl,
headers: {
'x-api-key': getApiKey(),
'Authorization': jwtToken,
},
});
const client = new ApolloClient({
link: link,
cache: new InMemoryCache(),
});
try {
yield put(setStatusMessage('Generating license code...', 'info'));
yield client.mutate({
/* tslint:disable */
mutation: gql`
}
mutation licensemutation($distributor: String!, licenceType: String!, duration: String, userId: String) {
addLicenseCodeOneTimeUsage(distributor: $distributor, licenseType: $licenseType, duration: $duration, userId: $userId) {
code
}
}
`,
/* tslint:enable */
variables: {
userId: username,
distributor: distributor,
licenseType: licenseType,
duration: duration,
},
});
const doneMessage = 'License code successfully generated';
yield put(generateSoftwareLicenseCodeSucceeded(doneMessage));
} catch (error) {
const errors = error.networkError.result.errors;
yield put(generateSoftwareLicenseCodeFailed(filterErrorMessage(errors)));
}
}
export function* softwareLicenseCodesSagas() {
const generateSoftwareLicenseCodeWatcher = yield takeLatest(GENERATE_SOFTWARE_LICENSE_CODE_ACTION, generateSoftwareLicenseCode);
yield take(LOCATION_CHANGE);
yield put(clearMessages());
yield cancel(generateSoftwareLicenseCodeWatcher);
}
The try block throws an error. The error
in the catch block is undefined.
The console shows uncaught at at at at b TypeError: Cannot read property 'result' of undefined
Stepping through the code takes me though a bunch of library code that I don't understand.
debugger
in js code, where you want to pause code execution. – Fairtrade