Something really weird happened

Everything was tested ok on my local host. I got the expected json response, and new doc was successfully created in mogodb collection. But on split, no matter how I try, there’s only orginal_url in the json response, no shor_url. The same code here and on my local machine. How can we explain this?

Your project link(s)

solution: boilerplate-project-urlshortener - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36

Challenge: Back End Development and APIs Projects - URL Shortener Microservice

Link to the challenge:
https://www.freecodecamp.org/learn/back-end-development-and-apis/back-end-development-and-apis-projects/url-shortener-microservice[https://boilerplate-project-urlshortener.robbinluo.repl.co](https://boilerplate-project-urlshortener.robbinluo.repl.co)

const urlSchema=new mongoose.Schema({
  original_url:{type:String, required:true},
  shortened_url:{type:Number, required:true}
});

This is a problem. When I forked your replit and sent a POST request with a valid url, I see the following error in the Node console. You should be seeing the same error.

/home/runner/boilerplate-project-urlshortener/node_modules/mongoose/lib/document.js:3051
    this.$__.validationError = new ValidationError(this);
                               ^

ValidationError: Url validation failed: shortened_url: Path `shortened_url` is required.
    at model.Document.invalidate (/home/runner/boilerplate-project-urlshortener/node_modules/mongoose/lib/document.js:3051:32)
    at /home/runner/boilerplate-project-urlshortener/node_modules/mongoose/lib/document.js:2839:17
    at /home/runner/boilerplate-project-urlshortener/node_modules/mongoose/lib/schematype.js:1340:9
    at processTicksAndRejections (node:internal/process/task_queues:78:11) {
  errors: {
    shortened_url: ValidatorError: Path `shortened_url` is required.
        at validate (/home/runner/boilerplate-project-urlshortener/node_modules/mongoose/lib/schematype.js:1337:13)
        at SchemaNumber.SchemaType.doValidate (/home/runner/boilerplate-project-urlshortener/node_modules/mongoose/lib/schematype.js:1321:7)
        at /home/runner/boilerplate-project-urlshortener/node_modules/mongoose/lib/document.js:2831:18
        at processTicksAndRejections (node:internal/process/task_queues:78:11) {
      properties: {
        validator: [Function (anonymous)],
        message: 'Path `shortened_url` is required.',
        type: 'required',
        path: 'shortened_url',
        value: undefined
      },
      kind: 'required',
      path: 'shortened_url',
      value: undefined,
      reason: undefined,
      [Symbol(mongoose:validatorError)]: true
    }
  },
  _message: 'Url validation failed'
}

Your schema references shortened_url but in several places in your code, I see you try to reference short_url in the database.

I really don’t know how this happened. I saw that residual sometimes as well, but I promise I fixed that key name (everywhere) before I post this question here. Sometimes it’s really head-scratching to work with replit. But I don’t know anywhere else should I complete these tasks to get the certificate. I would say it would be much fast if I can submit the result running on my local machine to the solution.

Our projects won’t let you submit a local URL as that’s typically not a persistent public site.

But there are plenty of options besides replit.

Thanks. May I ask for some recommendations?