3

I have a collection of book objects in memory,

book { title: string, author: string, description: string }

Now the url for searching book is

api/books/search/{text}

the real web api does check for matches in all attributes of books including author, title and description.

In the angular-in-memory-web-api I can have urls like,

api/books/?title={text}
api/books/?author={text}

etc.

Is there any way to have api/books/search/{text} this url working with the angular-in-memory-web-api?

1
  • 1
    did you find a solution? Commented Jan 26, 2018 at 12:24

1 Answer 1

3
+50

I'm not sure, but I think you've to override the parseRequestUrl method in your data service.

Example:

parseRequestUrl(url: string, utils: RequestInfoUtilities): ParsedRequestUrl {
  const newUrl = url.replace('/books/search/', '/books/?title=');
  const parsed = utils.parseRequestUrl(newUrl);
  return parsed;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.