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

219
Views
NULL Publicar datos en Service Worker usando Fetch API

Tengo este código en mi archivo de trabajador de servicio que guarda la suscripción de PushMessage:

 var hostURI = window.location.protocol + "//" + window.location.host; async function saveSubscription(subscription) { await fetch(hostURI + 'app/saveToken', { method: 'POST', mode: 'cors', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', }, cache: 'default', body: JSON.stringify(subscription) //PushMessage object }) .then(response => response.json()) .then(data => console.log(data)); //check response }

Esto funciona bien en mi servidor local, pero en el servidor de producción, el backend (PHP) dice que los datos POST son NULL. Este es mi código de prueba en el lado del servidor:

 public function saveToken() { $postData = (array) $this->request->getPost(); // get all post data $data['post'] = $postData; return $this->response->setJSON($data); // return as json }

Para obtener más información, no sé si esto está relacionado, pero mi aplicación está en el subenlace, por lo que mi URL base es www.website.com/app .

Estoy usando CodeIgniter4 e IIS en el lado del servidor.

about 4 years ago · Juan Pablo Isaza
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!