Giter Site home page Giter Site logo

204 response from API about elm-jwt HOT 8 CLOSED

simonh1000 avatar simonh1000 commented on September 26, 2024
204 response from API

from elm-jwt.

Comments (8)

simonh1000 avatar simonh1000 commented on September 26, 2024 1

Ok, I will split up the functions a little more

from elm-jwt.

simonh1000 avatar simonh1000 commented on September 26, 2024

have you tried

emptyDecoder : Json.Decoder String
emptyDecoder =
    Json.succeed "true"

If that does not work, then you have to build your request object yourself. For example

let 
  req = createRequest method token url body (Json.succeed "")
  req_ = { req | expect = Http.expectString }
...

from elm-jwt.

joshhornby avatar joshhornby commented on September 26, 2024

Thanks for the response @simonh1000

Json.succeed "true" doesn't work, can you prove the full example for building a request object? What needs to be in the in part of the let block?

from elm-jwt.

simonh1000 avatar simonh1000 commented on September 26, 2024

See https://github.com/simonh1000/elm-jwt/blob/master/src/Jwt.elm#L190 and use expectText instead

from elm-jwt.

MazeChaZer avatar MazeChaZer commented on September 26, 2024

I'm having the same issue for DELETE requests where the response obviously has no body.

from elm-jwt.

simonh1000 avatar simonh1000 commented on September 26, 2024

See https://github.com/simonh1000/elm-jwt/blob/master/examples/phoenix/web/elm/App.elm#L323 for example of how I would now tackle this issue with the 5.0.0 release of elm-jwt

from elm-jwt.

MazeChaZer avatar MazeChaZer commented on September 26, 2024

I'm not 100% percent sure, but I think using (Json.succeed "") will not work. Before the decoder is even applied to the response, JSON.parse() is called because the expectJson part is still hardcoded in the request creation method. But the JSON parsing will fail for an empty response. I think the solution would be not to assume that the response contains any kind of JSON and remove the expectJson from the function.

from elm-jwt.

simonh1000 avatar simonh1000 commented on September 26, 2024

I'm going to remove the expectJson as this is a library for accessing an authenticated REST API. But the change I published yesterday makes it quite possible to change the expect to something else.

from elm-jwt.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.