Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

API Mocks #1437

Unanswered
jachin asked this question in Q&A
May 5, 2021 · 1 comments · 1 reply
Discussion options

hi there

I'm setting up @web/dev-server for a small-ish project that used webpack before. I'm trying to figure out the best way to hook up some mock API responses.

I've tried using a middleware proxy but, I'm not sure exactly what I want. It looks very straight forward to send (some) requests (based on the pattern of the URL) to a different server. However what I want to do seems like it's simpler, which is just server up json files.

I've tried rewriting the requests, but I'm getting errors about changing headers after the body had already been sent.

I think I could figure out a solution to this using some KOA middleware, but it all seem more complicated than it should be.

Does anyone have an example handy they could point me to?

Thanks

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

Hello! Do you have any update or have you found any solution on this? I have some middleware that serves json files well for web-dev-server, but I can't figure out why it doesn't work for the test runner. I get 404 when I try to call the same mock APIs from web-test-runner.

You must be logged in to vote
1 reply
Comment options

jachin Jun 28, 2022
Author Sponsor

I'm afraid I have not. I went back and looked at what I think was the web component I was working on at the time, just to see, other people have worked on it in the mean time but I don't think we ever figured anything out.

It sounds like you got further than I did.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /