samedi 2 mars 2019

getting a 200 status but still an error when using POST in angular 4

I have 2 POSTs that are running through a promise, but regardless of which one is on the inside, they are hitting the catch and not executing the inside POST.

I have the following code:

this.http.post(medurl, datamed)
    .toPromise()
    .then(response => {
      console.log('Post Success!');
      console.log('Reponse: ' + response);

      if (response != 0){
        this.http.post(scripturl, datascript)
            .toPromise()
            .then(response => {
            console.log('Post Success!');
            console.log('Reponse: ' + response);
            })
            .catch(error => {
            console.log('Post Error!');
            console.log('Reponse: ' + typeof(error));
            });
       }

    })
    .catch(error => {
      console.log('Post Error!');
      console.log('Reponse: ' + typeof(error));
    });

I'm not sure what the issue is, because I've double-triple checked the fields for the POSTs, and they're working just fine in a different context, plus the response is a 200.

I'm not sure what other details to add here, but if you need more info let me know.




Aucun commentaire:

Enregistrer un commentaire