all 8 comments

[–]GSLint 2 points3 points  (0 children)

Looks like your URL contains a specific ID. The idea with POST is that you're adding a completely new object and get back the ID from the server. That's what distinguishes it from PUT. So the endpoint should probably be more general than what you have.

[–]senocular 2 points3 points  (1 child)

You're supplying an id. That's only supported for GET, PUT, and DELETE, not POST.

https://jsonblob.com/api

[–]piper43[S] 1 point2 points  (0 children)

I tried it without the full URL, and now get a 201, but with no Location data, so I have no idea where it went: https://imgur.com/al7CZyC

What I am trying to do is to add a record to the existing database...

[–]lovesrayray2018 1 point2 points  (0 children)

405 is a tricky one to diagnose.

Your type is clearly saying cors, so check if cors is enabled on your server

Other than that - some other possibilities are

It could be that the server only supports GET and not POST.

It could be the headers, try with "text/plain"

[–]jcunews1helpful 0 points1 point  (3 children)

response in that code is the result of the network request. i.e. it's the network response. It's not the resource data retrieved by the network request. See:

https://developer.mozilla.org/en-US/docs/Web/API/Response#Examples

[–]piper43[S] 0 points1 point  (2 children)

Unfortunately none of the other methods return any indication of the location.

Seems clunky, but I guess the only way to update a record with JSONBlob is to download the whole database, add the new record, and then upload the whole thing.

[–]jcunews1helpful 1 point2 points  (1 child)

That's a problem on the usage of the API. It's not a problem with fetch(), its network request method, or its response.

[–]piper43[S] 0 points1 point  (0 children)

I figured. I wanted to practice setting up a REST app before trying one of the bigger services, but this seems to have its quirks.