Skip to content

Commit

Permalink
fix undefined error
Browse files Browse the repository at this point in the history
  • Loading branch information
MineFact committed Feb 2, 2024
1 parent 490afcd commit db8cb5b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/routes/teams/POST_Warp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function initRoutes(app: Router, joi: any, network: Network) {
const countryCodeType = req.body.countryCodeType; // Country Code Type like cca2, cca3, ccn3, or cioc.
const address = req.body.address; // The address of the warp.
const addressType: AddressType = convertStringToAddressType(req.body.addressType); // The type of address. (BUILDING, STREET, CITY, STATE, COUNTRY, CUSTOM)
const material = req.body.material; // The material of the warp.
let material = req.body.material; // The material of the warp.

const worldName = req.body.worldName; // The name of the world the warp is in.
const lat = req.body.lat; // The latitude of the warp.
Expand All @@ -66,11 +66,16 @@ export async function initRoutes(app: Router, joi: any, network: Network) {
const isHighlight = req.body.isHighlight; // Whether the warp is a highlight or not.


// If the addressType is CUSTOM and the address is not specified, return an error
if(addressType == AddressType.CUSTOM && address == null){
res.status(400).send({success: false, error: 'Address must be specified when addressType is CUSTOM'});
return;
}

// If the material is not specified, set it to null
if(material == undefined)
material = null;

// Create a new warp
const promise = buildTeam.createWarp(id, warpGroupID, name, countryCode, countryCodeType, address, addressType, material, worldName, lat, lon, y, yaw, pitch, isHighlight);

Expand Down
3 changes: 3 additions & 0 deletions src/routes/teams/PUT_Warp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ export async function initRoutes(app: Router, joi: any, network: Network) {
return;
}

if(material == undefined)
material = null;


// Update the warp
const promise = buildTeam.updateWarp(id, warpGroupID, name, countryCode, countryCodeType, address, addressType, material, worldName, lat, lon, y, yaw, pitch, isHighlight);
Expand Down

0 comments on commit db8cb5b

Please sign in to comment.