Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

591
Views
Vue sends a null parameters in object in axios post request

So as title says, the problem is that I send a request from Vue using axios which has data on the parameters when I'm sending them (I see it using a console.log), but when I get the request on C# (.NET Core) those parameters are null. If there is more info or code needed just let me know.

Thanks.

Vue:

methods: {
    translate() {
      //This log RETURNS DATA, so parameters aren't null at this moment
      console.log(this.textToTranslate, this.fromLanguage, this.toLanguage);
      axios
        .post(
          "http://localhost:5000/api/Translate",
          {
            TranslateRequest: {
              textToTranslate: this.textToTranslate,
              fromLanguage: this.fromLanguage,
              toLanguage: this.toLanguage,
            },
          },
          {
            headers: {
              "Access-Control-Allow-Origin": "*",
              "Access-Control-Allow-Methods":
                "GET, POST, PATCH, PUT, DELETE, OPTIONS",
              "Access-Control-Allow-Headers":
                "Origin, Content-Type, X-Auth-Token",
            },
          }
        )
        .then((res) => {
          console.log(res);
          this.translatedText = res.data;
        })
        .catch((err) => {
          console.log(err.response);
          alert(err.response);
        });
    },
  },

C#:

    [ApiController]
    [Route("api/[controller]")]
    public class TranslateController : ControllerBase
    {
        [EnableCors("AllowOrigin")]
        [HttpGet]
        public string GetTranslatedText(TranslateRequest request)
        {
            //request object isn't null but their parameters are
            return TranslateText(request);
        }
     }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Your problem is here:

{
    "TranslateRequest":{
        "textToTranslate":"this.textToTranslate",
        "fromLanguage":"this.fromLanguage",
        "toLanguage":"this.toLanguage"
    }
}

Pass data as below:

{
    "textToTranslate":"this.textToTranslate",
    "fromLanguage":"this.fromLanguage",
    "toLanguage":"this.toLanguage"
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!